* Web.csproj:

* jquery-latest.js:
* IITContent.cs:
* ITContent.csproj:
* YavscModel.csproj:
* Write.aspx:
* jquery.tablesorter.min.js:
* AssemblyInfo.cs:
* NewEstimateEvenArgs.cs: 

* jquery.metadata.js: ajax call Write

* jquery.tablesorter.js: Estimate table sorting

* Catalog.cs: Find a product by reference

* NpgsqlContentProvider.cs: Npgsql provider could not get the
  Postgresql data type "money"

* Yavsc.sln: Removing an empty project

* MyClass.cs: implements IModule

* fortune.csproj: uses Configuration

* FrontOfficeApiController.cs: Url: GetEstimate/5

* WorkFlowController.cs: debugging ajax call

* RemoveUserQuery.aspx: no more "head" place holder


* Estimate.aspx: Ajax call to add a line to estimates

* Web.config: using the "Deploy" target

* IModule.cs: Install & uninstall using a System.Data.IDbConnection

* IContentProvider.cs: refactoring

* WorkFlowManager.cs: an event at creating an estimate (NewOrder)

* Writting.cs: ProductReference is a string
This commit is contained in:
Paul Schneider 2014-10-17 02:10:00 +02:00
commit f157c6edb9
25 changed files with 1569 additions and 167 deletions

View file

@ -12,6 +12,16 @@ namespace WorkFlowProvider
{
public class NpgsqlContentProvider: ProviderBase, IContentProvider
{
public void Install (System.Data.IDbConnection cnx)
{
throw new NotImplementedException ();
}
public void Uninstall (System.Data.IDbConnection cnx, bool removeConfig)
{
throw new NotImplementedException ();
}
public Estimate[] GetEstimates (string client)
{
throw new NotImplementedException ();
@ -93,7 +103,7 @@ namespace WorkFlowProvider
throw new NotImplementedException ();
}
public string[] StatusLabels {
public string[] Statuses {
get {
return new string[] { "Created", "Validated", "Success", "Error" };
}
@ -153,27 +163,30 @@ namespace WorkFlowProvider
est.Owner = rdr.GetString(
rdr.GetOrdinal("username"));
est.Id = estimid;
using (NpgsqlCommand cmdw = new NpgsqlCommand ("select _id, productid, ucost, count, description from writtings where _id = @estid", cnx)) {
using (NpgsqlCommand cmdw = new NpgsqlCommand ("select _id, productid, ucost, count, description from writtings where estimid = @estid", cnx)) {
cmdw.Parameters.Add("@estid", estimid);
using (NpgsqlDataReader rdrw = cmdw.ExecuteReader ()) {
List<Writting> lw = new List<Writting> ();
while (rdrw.Read ()) {
Writting w = new Writting ();
w.Description = rdrw.GetString (
rdrw.GetOrdinal ("description"));
int opi = rdrw.GetOrdinal ("productid");
if (!rdrw.IsDBNull(opi))
w.ProductReference = rdrw.GetInt64(opi);
int oco = rdrw.GetOrdinal ("count");
if (!rdrw.IsDBNull(oco))
w.Count = rdrw.GetInt32 (oco);
int ouc = rdrw.GetOrdinal ("ucost");
if (!rdrw.IsDBNull(ouc))
w.UnitaryCost = rdrw.GetDecimal (ouc);
w.Id = rdrw.GetInt64 (rdrw.GetOrdinal("_id"));
lw.Add (w);
List<Writting> lw = null;
if (rdrw.HasRows) {
lw = new List<Writting> ();
while (rdrw.Read ()) {
Writting w = new Writting ();
w.Description = rdrw.GetString (
rdrw.GetOrdinal ("description"));
int opi = rdrw.GetOrdinal ("productid");
if (!rdrw.IsDBNull (opi))
w.ProductReference = rdrw.GetString(opi);
int oco = rdrw.GetOrdinal ("count");
if (!rdrw.IsDBNull (oco))
w.Count = rdrw.GetInt32 (oco);
int ouc = rdrw.GetOrdinal ("ucost");
if (!rdrw.IsDBNull (ouc))
w.UnitaryCost = rdrw.GetDecimal (ouc);
w.Id = rdrw.GetInt64 (rdrw.GetOrdinal ("_id"));
lw.Add (w);
}
est.Lines = lw.ToArray ();
}
est.Lines = lw.ToArray ();
}
}
// TODO est.Ciffer = somme des ecritures
@ -200,17 +213,21 @@ namespace WorkFlowProvider
}
}
public long Write (long estid, string desc, decimal ucost, int count, long productid)
public long Write (long estid, string desc, decimal ucost, int count, string productid)
{
using (NpgsqlConnection cnx = CreateConnection ()) {
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
cmd.CommandText =
"insert into writtings (description, estimid) VALUES (@dscr,@estid) returning _id";
"insert into writtings (description, estimid, ucost, count, productid) VALUES (@dscr,@estid,@ucost,@count,@prdid) returning _id";
cmd.Parameters.Add ("@dscr", desc);
// cmd.Parameters.Add ("@prdid", productid);
// cmd.Parameters.Add("@ucost", ucost);
// cmd.Parameters.Add("@mult", count);
cmd.Parameters.Add("@estid", estid);
cmd.Parameters.Add("@ucost", ucost);
cmd.Parameters.Add("@count", count);
cmd.Parameters.Add("@prdid", productid);
cnx.Open ();
long res = (long) cmd.ExecuteScalar ();