public static void update(Guid userAccountID, Guid id, int priorityNo, int priorityQty, DateTime?expectedDeliveryDate) { POItem objOld = new POItem(id); //generate log description string log = ""; log = ActivityLog.appendChange(log, objOld.ExpectedDeliveryDate, expectedDeliveryDate, "Expected Delivery: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.PriorityNo, priorityNo, "Priority No: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.PriorityQty, priorityQty, "Priority Qty: '{0}' to '{1}'"); if (!string.IsNullOrEmpty(log)) { SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "poitem_update", new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, id), new SqlQueryParameter(COL_DB_PriorityNo, SqlDbType.SmallInt, Util.wrapNullable(priorityNo)), new SqlQueryParameter(COL_DB_PriorityQty, SqlDbType.Int, Util.wrapNullable(priorityQty)), new SqlQueryParameter(COL_DB_ExpectedDeliveryDate, SqlDbType.Date, Util.wrapNullable(expectedDeliveryDate)) ); if (result.IsSuccessful) { ActivityLog.submit(id, log); } } }
public static bool update(Guid Id, DateTime Timestamp, Guid?Customers_Id, Guid?Vendors_Id, string No, decimal DPP, decimal PPN, string Notes) { FakturPajak objOld = new FakturPajak(Id); string log = ""; log = Util.appendChange(log, objOld.No, No, "No: '{0}' to '{1}'"); log = Util.appendChange(log, objOld.Timestamp, Timestamp, "Date: '{0:dd/MM/yy}' to '{1:dd/MM/yy}'"); log = Util.appendChange(log, objOld.DPP, DPP, "DPP: '{0}' to '{1}'"); log = Util.appendChange(log, objOld.PPN, PPN, "PPN: '{0}' to '{1}'"); log = Util.appendChange(log, objOld.Notes, Notes, "Notes: '{0}' to '{1}'"); string newCustomerName = new Customer(Customers_Id).Name; if (objOld.Customers_Name != newCustomerName) { log = Util.appendChange(log, objOld.Customers_Name, newCustomerName, "Customer: '{0}' to '{1}'"); if (!Util.displayMessageBoxYesNo("Sale Invoices and Returns will be removed because customer is changed")) { return(false); } } string newVendorName = new Vendor(Vendors_Id).Name; if (objOld.Vendors_Name != newVendorName) { log = Util.appendChange(log, objOld.Vendors_Name, newVendorName, "Vendor: '{0}' to '{1}'"); if (!Util.displayMessageBoxYesNo("Vendor Invoices and Returns will be removed because vendor is changed")) { return(false); } } if (!string.IsNullOrEmpty(log)) { SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "FakturPajaks_update", new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, Id), new SqlQueryParameter(COL_DB_Timestamp, SqlDbType.DateTime, Timestamp), new SqlQueryParameter(COL_DB_Customers_Id, SqlDbType.UniqueIdentifier, Util.wrapNullable(Customers_Id)), new SqlQueryParameter(COL_DB_Vendors_Id, SqlDbType.UniqueIdentifier, Util.wrapNullable(Vendors_Id)), new SqlQueryParameter(COL_DB_No, SqlDbType.VarChar, No), new SqlQueryParameter(COL_DB_DPP, SqlDbType.Decimal, DPP), new SqlQueryParameter(COL_DB_PPN, SqlDbType.Decimal, PPN), new SqlQueryParameter(COL_DB_Notes, SqlDbType.NVarChar, Util.wrapNullable(Notes)) ); if (result.IsSuccessful) { ActivityLog.submit(Id, String.Format("Updated: {0}", log)); } return(result.IsSuccessful); } return(true); }
/*******************************************************************************************************/ #region CONSTRUCTORS #endregion CONSTRUCTORS /*******************************************************************************************************/ #region DATABASE METHODS #endregion DATABASE METHODS /*******************************************************************************************************/ #region DATABASE STATIC METHODS public static Guid?add(Guid vendorId, decimal amount, Guid?salePaymentID, string notes, PaymentMethod?paymentMethod) { Guid Id = Guid.NewGuid(); SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "VendorDebits_add", new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, Id), new SqlQueryParameter(COL_DB_Vendors_Id, SqlDbType.UniqueIdentifier, vendorId), new SqlQueryParameter(COL_DB_Amount, SqlDbType.Decimal, amount), new SqlQueryParameter(COL_DB_sale_payment_id, SqlDbType.UniqueIdentifier, Util.wrapNullable(salePaymentID)), new SqlQueryParameter(COL_DB_Type_enumid, SqlDbType.TinyInt, Util.wrapNullable(paymentMethod)), new SqlQueryParameter(COL_DB_Notes, SqlDbType.VarChar, Util.wrapNullable(notes)) ); if (!result.IsSuccessful) { return(null); } else { ActivityLog.submit(vendorId, "Debit: Rp." + amount.ToString("N2")); return(Id); } }
public static bool update(Guid Id, int CorrectionAmount, string CorrectionNotes, DateTime?PaymentDate) { SaleComission objOld = new SaleComission(Id); string log = ""; log = Util.appendChange(log, objOld.CorrectionAmount, CorrectionAmount, "Correction Amount: '{0}' to '{1}'"); log = Util.appendChange(log, objOld.CorrectionNotes, CorrectionNotes, "Correction Notes: '{0}' to '{1}'"); log = Util.appendChange(log, objOld.PaymentDate, PaymentDate, "Payment Date: '{0:dd/MM/yyyy}' to '{1:dd/MM/yyyy}'"); if (!string.IsNullOrEmpty(log)) { SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "SaleComissions_update", new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, Id), new SqlQueryParameter(COL_DB_CorrectionAmount, SqlDbType.Int, CorrectionAmount), new SqlQueryParameter(COL_DB_CorrectionNotes, SqlDbType.VarChar, Util.wrapNullable(CorrectionNotes)), new SqlQueryParameter(COL_DB_PaymentDate, SqlDbType.DateTime, Util.wrapNullable(PaymentDate)) ); if (result.IsSuccessful) { ActivityLog.submit(Id, String.Format("Updated: {0}", log)); } return(result.IsSuccessful); } return(false); }
public static void delete(Guid id) { InventoryStockLevel obj = new InventoryStockLevel(id); //generate log description string logDescription = ""; logDescription = Tools.append(logDescription, String.Format("Product Store Name: '{0}'", obj.ProductStoreName), ","); logDescription = Tools.append(logDescription, String.Format("Grade: '{0}'", obj.GradeName), ","); logDescription = Tools.append(logDescription, String.Format("Product Width: '{0}'", obj.ProductWidthName), ","); logDescription = Tools.append(logDescription, String.Format("Length Unit: '{0}'", obj.LengthUnitName), ","); logDescription = Tools.append(logDescription, String.Format("Vendor: '{0}'", obj.VendorName), ","); logDescription = Tools.append(logDescription, String.Format("Qty: '{0}'", obj.Qty), ","); logDescription = Tools.append(logDescription, String.Format("PO Notes: '{0}'", obj.PONotes), ","); logDescription = Tools.append(logDescription, String.Format("Notes: '{0}'", obj.Notes), ","); SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "inventorystocklevel_delete", new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, id) ); if (result.IsSuccessful) { ActivityLog.submit(id, String.Format("Deleted: {0}", logDescription)); } }
public static bool update(Guid Id, DateTime Timestamp, string Notes) { VendorInvoicePayment objOld = new VendorInvoicePayment(Id); string log = ""; log = Util.appendChange(log, objOld.Timestamp, Timestamp, "Date: '{0:dd/MM/yy}' to '{1:dd/MM/yy}'"); log = Util.appendChange(log, objOld.Notes, Notes, "Notes: '{0}' to '{1}'"); if (string.IsNullOrEmpty(log)) { return(Util.displayMessageBoxError("No changes to record")); } else { SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "VendorInvoicePayments_update", new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, Id), new SqlQueryParameter(COL_DB_Timestamp, SqlDbType.DateTime, Timestamp), new SqlQueryParameter(COL_DB_Notes, SqlDbType.NVarChar, Util.wrapNullable(Notes)) ); if (result.IsSuccessful) { ActivityLog.submit(Id, String.Format("Updated: {0}", log)); } return(result.IsSuccessful); } }
public static void delete(Guid id) { CustomerSaleAdjustment obj = new CustomerSaleAdjustment(id); //generate log description string logDescription = ""; logDescription = Tools.append(logDescription, String.Format("Customer Name: '{0}'", obj.CustomerName), ","); logDescription = Tools.append(logDescription, String.Format("Product Store Name: '{0}'", obj.ProductStoreName), ","); logDescription = Tools.append(logDescription, String.Format("Grade: '{0}'", obj.GradeName), ","); logDescription = Tools.append(logDescription, String.Format("Product Width: '{0}'", obj.ProductWidthName), ","); logDescription = Tools.append(logDescription, String.Format("Unit: '{0}'", obj.LengthUnitName), ","); logDescription = Tools.append(logDescription, String.Format("Adjustment: '{0}'", obj.AdjustmentPerUnit), ","); logDescription = Tools.append(logDescription, String.Format("Notes: '{0}'", obj.Notes), ","); SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "customersaleadjustment_delete", new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, id) ); if (result.IsSuccessful) { ActivityLog.submit(id, String.Format("Item deleted: {0}", logDescription)); } }
public static void update(Guid id, Guid pettyCashRecordsCategories_Id, decimal amount, string notes) { PettyCashRecord objOld = new PettyCashRecord(id); string log = ""; log = ActivityLog.appendChange(log, objOld.PettyCashRecordsCategories_Name, new PettyCashRecordsCategory(pettyCashRecordsCategories_Id).Name, "Category: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.Amount, amount, "Amount: '{0:N2}' to '{1:N2}'"); log = ActivityLog.appendChange(log, objOld.Notes, notes, "Notes: '{0}' to '{1}'"); if (!string.IsNullOrEmpty(log)) { SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "PettyCashRecords_update", new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, id), new SqlQueryParameter(COL_DB_PettyCashRecordsCategories_Id, SqlDbType.UniqueIdentifier, pettyCashRecordsCategories_Id), new SqlQueryParameter(COL_DB_Amount, SqlDbType.Decimal, amount), new SqlQueryParameter(COL_DB_Notes, SqlDbType.VarChar, Util.wrapNullable(notes)) ); if (result.IsSuccessful) { if (GlobalData.UserAccount.role != Roles.Super) { ActivityLog.submit(id, "UPDATE: " + log, (int)Roles.Super); } else { ActivityLog.submit(id, "UPDATE: " + log); } } } }
public static void update(Guid id, string description, decimal sellAmountPerUnit, int qty, string notes) { try { string log = ""; GordenOrderItem objOld = new GordenOrderItem(id); log = ActivityLog.appendChange(log, objOld.Description, description, "Description: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.SellAmountPerUnit, sellAmountPerUnit, "Sell Amount Per Unit: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.Qty, qty, "Qty: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.Notes, notes, "Notes: '{0}' to '{1}'"); using (SqlCommand cmd = new SqlCommand("gordenorderitem_update", DBConnection.ActiveSqlConnection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@" + COL_DB_ID, SqlDbType.UniqueIdentifier).Value = id; cmd.Parameters.Add("@" + COL_DB_DESCRIPTION, SqlDbType.VarChar).Value = description; cmd.Parameters.Add("@" + COL_DB_SELLAMOUNTPERUNIT, SqlDbType.Decimal).Value = sellAmountPerUnit; cmd.Parameters.Add("@" + COL_DB_QTY, SqlDbType.Int).Value = qty; cmd.Parameters.Add("@" + COL_DB_NOTES, SqlDbType.VarChar).Value = Util.wrapNullable(notes); cmd.ExecuteNonQuery(); ActivityLog.submit(id, String.Format("Item updated: {0}", log)); } } catch (Exception ex) { Tools.showError(ex.Message); } }
public static void add(string name, GordenItemCategories category, Guid vendorID, Guid retailLengthUnitID, Guid bulkLengthUnitID, Guid?productWidthID, decimal buyRetailPricePerUnit, decimal buyBulkPricePerUnit, decimal sellRetailPricePerUnit, decimal sellBulkPricePerUnit, string notes) { try { Guid id = Guid.NewGuid(); using (SqlCommand cmd = new SqlCommand("gordenitem_add", DBConnection.ActiveSqlConnection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@" + COL_DB_ID, SqlDbType.UniqueIdentifier).Value = id; cmd.Parameters.Add("@" + COL_DB_NAME, SqlDbType.VarChar).Value = name; cmd.Parameters.Add("@" + COL_DB_CATEGORYENUMID, SqlDbType.TinyInt).Value = category; cmd.Parameters.Add("@" + COL_DB_VENDORID, SqlDbType.UniqueIdentifier).Value = vendorID; cmd.Parameters.Add("@" + COL_DB_PRODUCTWIDTHID, SqlDbType.UniqueIdentifier).Value = Util.wrapNullable(productWidthID); cmd.Parameters.Add("@" + COL_DB_RETAILLENGTHUNITID, SqlDbType.UniqueIdentifier).Value = retailLengthUnitID; cmd.Parameters.Add("@" + COL_DB_BULKLENGTHUNITID, SqlDbType.UniqueIdentifier).Value = bulkLengthUnitID; cmd.Parameters.Add("@" + COL_DB_BUYRETAILPRICEPERUNIT, SqlDbType.Decimal).Value = Util.wrapNullable(buyRetailPricePerUnit); cmd.Parameters.Add("@" + COL_DB_BUYBULKPRICEPERUNIT, SqlDbType.Decimal).Value = Util.wrapNullable(buyBulkPricePerUnit); cmd.Parameters.Add("@" + COL_DB_SELLRETAILPRICEPERUNIT, SqlDbType.Decimal).Value = Util.wrapNullable(sellRetailPricePerUnit); cmd.Parameters.Add("@" + COL_DB_SELLBULKPRICEPERUNIT, SqlDbType.Decimal).Value = Util.wrapNullable(sellBulkPricePerUnit); cmd.Parameters.Add("@" + COL_DB_NOTES, SqlDbType.VarChar).Value = Util.wrapNullable(notes); cmd.ExecuteNonQuery(); ActivityLog.submit(id, "Item created"); } Tools.hasMessage("Item created"); } catch (Exception ex) { Tools.showError(ex.Message); } }
public static void update(Guid id, string name, string notes) { PettyCashRecordsCategory objOld = new PettyCashRecordsCategory(id); string log = ""; log = ActivityLog.appendChange(log, objOld.Name, name, "Name: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.Notes, notes, "Notes: '{0}' to '{1}'"); if (!string.IsNullOrEmpty(log)) { SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "PettyCashRecordsCategories_update", new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, id), new SqlQueryParameter(COL_DB_Name, SqlDbType.VarChar, Util.wrapNullable(name)), new SqlQueryParameter(COL_DB_Notes, SqlDbType.VarChar, Util.wrapNullable(notes)) ); if (result.IsSuccessful) { ActivityLog.submit(id, "UPDATE: " + log); } } }
/*******************************************************************************************************/ #region DATABASE METHODS public static string add(Guid id, Guid customerID, string customerInfo, decimal discountAmount, decimal otherCharges, string notes, DataTable gordenOrderItems, List <GordenOrderItemMaterial> materials) { string no = ""; try { using (SqlCommand cmd = new SqlCommand("gordenorder_add", DBConnection.ActiveSqlConnection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@" + COL_DB_ID, SqlDbType.UniqueIdentifier).Value = id; cmd.Parameters.Add("@" + COL_DB_CUSTOMERID, SqlDbType.UniqueIdentifier).Value = customerID; cmd.Parameters.Add("@" + COL_DB_CUSTOMERINFO, SqlDbType.VarChar).Value = customerInfo; cmd.Parameters.Add("@" + COL_DB_DISCOUNTAMOUNT, SqlDbType.Decimal).Value = discountAmount; cmd.Parameters.Add("@" + COL_DB_OTHERCHARGES, SqlDbType.Decimal).Value = otherCharges; cmd.Parameters.Add("@" + COL_DB_NOTES, SqlDbType.VarChar).Value = Util.wrapNullable(notes); SqlParameter return_value = cmd.Parameters.Add("@return_value", SqlDbType.Int); return_value.Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); no = Convert.ToInt32(return_value.Value).ToString(); ActivityLog.submit(id, "Item added"); GordenOrderItem.addItems(gordenOrderItems); GordenOrderItemMaterial.addItems(materials); } } catch (Exception ex) { Tools.showError(ex.Message); } return(no); }
/*******************************************************************************************************/ #region DATABASE METHODS //public static void add(string notes) //{ // Guid id = Guid.NewGuid(); // try // { // using (SqlConnection conn = new SqlConnection(DBUtil.connectionString)) // using (SqlCommand cmd = new SqlCommand("gordenorderitemmaterial_add", conn)) // { // cmd.CommandType = CommandType.StoredProcedure; // cmd.Parameters.Add("@" + COL_DB_ID, SqlDbType.UniqueIdentifier).Value = id; // cmd.Parameters.Add("@" + COL_DB_NOTES, SqlDbType.VarChar).Value = Util.wrapNullable(notes); // conn.Open(); // cmd.ExecuteNonQuery(); // ActivityLog.submit(conn, id, "Item added"); // } // } // catch (Exception ex) { Tools.showError(ex.Message); } //} public static void addItems(List <GordenOrderItemMaterial> materials) { try { foreach (GordenOrderItemMaterial material in materials) { using (SqlCommand cmd = new SqlCommand("gordenorderitemmaterial_add", DBConnection.ActiveSqlConnection)) { Guid id = Guid.NewGuid(); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@" + COL_DB_ID, SqlDbType.UniqueIdentifier).Value = id; cmd.Parameters.Add("@" + COL_DB_GORDENORDERITEMID, SqlDbType.UniqueIdentifier).Value = material.GordenOrderItemID; cmd.Parameters.Add("@" + COL_DB_GORDENITEMID, SqlDbType.UniqueIdentifier).Value = material.GordenItemID; cmd.Parameters.Add("@" + COL_DB_DESCRIPTION, SqlDbType.UniqueIdentifier).Value = material.Description; cmd.Parameters.Add("@" + COL_DB_BUYAMOUNTPERUNIT, SqlDbType.UniqueIdentifier).Value = material.BuyAmountPerUnit; cmd.Parameters.Add("@" + COL_DB_QTY, SqlDbType.UniqueIdentifier).Value = material.Qty; cmd.Parameters.Add("@" + COL_DB_NOTES, SqlDbType.VarChar).Value = Util.wrapNullable(material.Notes); cmd.ExecuteNonQuery(); ActivityLog.submit(id, "Item added"); } } } catch (Exception ex) { Tools.showError(ex.Message); } }
public static bool updateSaleOrderItem(Guid id, Guid?SaleOrderItems_Id, string description) { SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "poitem_update_SaleOrderItems_Id", new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, id), new SqlQueryParameter(COL_DB_SaleOrderItems_Id, SqlDbType.UniqueIdentifier, Util.wrapNullable(SaleOrderItems_Id)) ); if (!result.IsSuccessful) { return(false); } else if (SaleOrderItems_Id == null) { ActivityLog.submit(id, "Sale Order Item removed"); } else { ActivityLog.submit(id, "Sale Order Item Updated to: " + description); } return(true); }
public static void update_FakturPajaks_Id(Guid Id, Guid?FakturPajaks_Id) { VendorInvoice objOld = new VendorInvoice(Id); //generate log description string log = ""; log = ActivityLog.appendChange(log, objOld.FakturPajaks_No, new FakturPajak(FakturPajaks_Id).No, "Faktur Pajak: '{0}' to '{1}'"); if (string.IsNullOrEmpty(log)) { Util.displayMessageBoxError("No changes to record"); } else { SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "VendorInvoices_update_FakturPajaks_Id", new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, Id), new SqlQueryParameter(COL_DB_FakturPajaks_Id, SqlDbType.UniqueIdentifier, FakturPajaks_Id) ); if (result.IsSuccessful) { ActivityLog.submit(Id, String.Format("Updated: {0}", log)); } } }
public static void update(Guid Id, DateTime Timestamp, string InvoiceNo, decimal Amount, int TOP, string Notes) { VendorInvoice objOld = new VendorInvoice(Id); //generate log description string log = ""; log = ActivityLog.appendChange(log, objOld.InvoiceNo, InvoiceNo, "Invoice No: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.Timestamp, Timestamp, "Timestamp: '{0:dd/MM/yy}' to '{1:dd/MM/yy}'"); log = Util.appendChange(log, objOld.Amount, Amount, "Amount: '{0:N2}' to '{1:N2}'"); log = ActivityLog.appendChange(log, objOld.TOP, TOP, "TOP: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.Notes, Notes, "Notes: '{0}' to '{1}'"); SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "VendorInvoices_update", new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, Id), new SqlQueryParameter(COL_DB_Timestamp, SqlDbType.DateTime, Timestamp), new SqlQueryParameter(COL_DB_InvoiceNo, SqlDbType.VarChar, InvoiceNo), new SqlQueryParameter(COL_DB_TOP, SqlDbType.Int, TOP), new SqlQueryParameter(COL_DB_Amount, SqlDbType.Decimal, Amount), new SqlQueryParameter(COL_DB_Notes, SqlDbType.NVarChar, Util.wrapNullable(Notes)) ); if (result.IsSuccessful) { ActivityLog.submit(Id, String.Format("Updated: {0}", log)); } }
public static void update(Guid id, string name, GordenItemCategories category, Guid vendorID, Guid retailLengthUnitID, Guid bulkLengthUnitID, Guid?productWidthID, decimal?buyRetailPricePerUnit, decimal?buyBulkPricePerUnit, decimal?sellRetailPricePerUnit, decimal?sellBulkPricePerUnit, string notes) { try { GordenItem objOld = new GordenItem(id); //generate log description string log = ""; log = ActivityLog.appendChange(log, objOld.Name, name, "Name: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.CategoryName, category, "Category: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.VendorID, new Vendor(vendorID).Name, "Vendor: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.ProductWidthID, new ProductWidth(productWidthID).Name, "Width: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.RetailLengthUnitID, new LengthUnit(retailLengthUnitID).Name, "Retail Unit: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.BulkLengthUnitID, new LengthUnit(bulkLengthUnitID).Name, "Bulk Unit: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.BuyRetailPricePerUnit, buyRetailPricePerUnit, "Buy Retail Price/Unit: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.BuyBulkPricePerUnit, buyBulkPricePerUnit, "Buy Bulk Price/Unit: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.SellRetailPricePerUnit, sellRetailPricePerUnit, "Sell Retail Price/Unit: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.SellBulkPricePerUnit, sellBulkPricePerUnit, "Sell Bulk Price/Unit: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.Notes, notes, "Notes: '{0}' to '{1}'"); if (string.IsNullOrEmpty(log)) { Tools.showError("No changes to record"); } else { using (SqlCommand cmd = new SqlCommand("gordenitem_update", DBConnection.ActiveSqlConnection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@" + COL_DB_ID, SqlDbType.UniqueIdentifier).Value = id; cmd.Parameters.Add("@" + COL_DB_NAME, SqlDbType.VarChar).Value = name; cmd.Parameters.Add("@" + COL_DB_CATEGORYENUMID, SqlDbType.TinyInt).Value = category; cmd.Parameters.Add("@" + COL_DB_VENDORID, SqlDbType.UniqueIdentifier).Value = vendorID; cmd.Parameters.Add("@" + COL_DB_PRODUCTWIDTHID, SqlDbType.UniqueIdentifier).Value = Util.wrapNullable(productWidthID); cmd.Parameters.Add("@" + COL_DB_RETAILLENGTHUNITID, SqlDbType.UniqueIdentifier).Value = retailLengthUnitID; cmd.Parameters.Add("@" + COL_DB_BULKLENGTHUNITID, SqlDbType.UniqueIdentifier).Value = bulkLengthUnitID; cmd.Parameters.Add("@" + COL_DB_BUYRETAILPRICEPERUNIT, SqlDbType.Decimal).Value = Util.wrapNullable(buyRetailPricePerUnit); cmd.Parameters.Add("@" + COL_DB_BUYBULKPRICEPERUNIT, SqlDbType.Decimal).Value = Util.wrapNullable(buyBulkPricePerUnit); cmd.Parameters.Add("@" + COL_DB_SELLRETAILPRICEPERUNIT, SqlDbType.Decimal).Value = Util.wrapNullable(sellRetailPricePerUnit); cmd.Parameters.Add("@" + COL_DB_SELLBULKPRICEPERUNIT, SqlDbType.Decimal).Value = Util.wrapNullable(sellBulkPricePerUnit); cmd.Parameters.Add("@" + COL_DB_NOTES, SqlDbType.VarChar).Value = Util.wrapNullable(notes); cmd.ExecuteNonQuery(); ActivityLog.submit(id, "UPDATE: " + log); } Tools.hasMessage("Item updated"); } } catch (Exception ex) { Tools.showError(ex.Message); } }
public static void update_ShippingExpense(Guid Id, Guid PettyCashRecordsCategories_Id, int Amount, string Notes) { Sale objOld = new Sale(Id); string log = ""; log = ActivityLog.appendChange(log, objOld.ShippingExpense, Amount, "Shipping Expense: '{0}' to '{1}'"); if (!string.IsNullOrEmpty(log)) { int PettyCashRecords_Amount = -1 * Amount; string PettyCashRecords_Notes = string.Format("Expense for Invoice {0}", objOld.barcode); //if there is previous amount value, adjust amount so petty cash is still correct. if (objOld.ShippingExpense > 0) { PettyCashRecords_Amount += objOld.ShippingExpense; PettyCashRecords_Notes += string.Format(" (Update {0:N0} to {1:N0})", objOld.ShippingExpense, Amount); } //transport information if (objOld.TransportName != null) { PettyCashRecords_Notes += string.Format(", Angkutan {0}", objOld.TransportName); } if (!string.IsNullOrWhiteSpace(Notes)) { PettyCashRecords_Notes += ", " + Notes; } Guid?PettyCashRecords_Id = PettyCashRecord.add(PettyCashRecordsCategories_Id, PettyCashRecords_Amount, PettyCashRecords_Notes); if (PettyCashRecords_Id != null) { log += string.Format(", Petty Cash {0} Amount: {1:N0}", new PettyCashRecord((Guid)PettyCashRecords_Id).No, PettyCashRecords_Amount); SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "Sales_update_ShippingExpense", new SqlQueryParameter(COL_ID, SqlDbType.UniqueIdentifier, Id), new SqlQueryParameter(COL_DB_ShippingExpense, SqlDbType.Int, Amount) ); if (result.IsSuccessful) { ActivityLog.submit(Id, String.Format("Updated: {0}", log)); } } } }
/*******************************************************************************************************/ #region DATABASE METHODS public Guid?submitNew() { //submit new sale record SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, false, true, false, false, false, "salereturn_new", new SqlQueryParameter(COL_ID, SqlDbType.UniqueIdentifier, id), new SqlQueryParameter(COL_DB_Timestamp, SqlDbType.DateTime, time_stamp), new SqlQueryParameter(COL_DB_Users_Id, SqlDbType.UniqueIdentifier, user_id), new SqlQueryParameter(COL_DB_Notes, SqlDbType.VarChar, Util.wrapNullable(notes)) ); if (!result.IsSuccessful) { return(null); } else { ActivityLog.submitCreate(id); barcode = Tools.getHex(result.ValueInt, Settings.saleBarcodeLength); } //mark sale items as returned foreach (DataRow row in saleReturnItems.Rows) { result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "saleitem_return", new SqlQueryParameter(COL_ID, SqlDbType.UniqueIdentifier, Util.wrapNullable <Guid>(row, SaleItem.COL_ID)), new SqlQueryParameter("return_id", SqlDbType.UniqueIdentifier, id) ); if (!result.IsSuccessful) { return(null); } else { ActivityLog.submit((Guid)row[SaleItem.COL_ID], "Sale Item returned in sale return ID: " + id.ToString()); ActivityLog.submit((Guid)row[SaleItem.COL_INVENTORY_ITEM_ID], "Returned in sale return ID: " + barcode); } } return(id); }
public static void updateDefaultRow(string storedProcedure, Guid id, string logDescription) { SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, storedProcedure, new SqlQueryParameter("id", SqlDbType.UniqueIdentifier, id) ); if (result.IsSuccessful) { ActivityLog.submit(id, logDescription); } }
public static void update_Kontrabons_Id(Guid Id, Guid?Kontrabons_Id) { FakturPajak objOld = new FakturPajak(Id); string log = ""; log = ActivityLog.appendChange(log, objOld.Kontrabons_No, new Kontrabon(Kontrabons_Id).No, "Kontrabon: '{0}' to '{1}'"); if (!string.IsNullOrEmpty(log)) { SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "FakturPajaks_update_Kontrabons_Id", new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, Id), new SqlQueryParameter(COL_DB_Kontrabons_Id, SqlDbType.UniqueIdentifier, Util.wrapNullable(Kontrabons_Id)) ); if (result.IsSuccessful) { ActivityLog.submit(Id, String.Format("Updated: {0}", log)); //update faktur pajak log if (Kontrabons_Id == null) { ActivityLog.submit((Guid)objOld.Kontrabons_Id, String.Format("Removed FP: {0}", objOld.No)); } else { ActivityLog.submit((Guid)Kontrabons_Id, String.Format("Added FP: {0}", objOld.No)); } //remove sale invoices DataTable saleInvoices = Sale.get_by_FakturPajaks_Id(Id); foreach (DataRow row in saleInvoices.Rows) { Sale.update_Kontrabons_Id(Util.wrapNullable <Guid>(row, Sale.COL_ID), Kontrabons_Id); } //remove sale returns DataTable saleReturns = SaleReturn.get_by_FakturPajaks_Id(Id); foreach (DataRow row in saleReturns.Rows) { SaleReturn.update_Kontrabons_Id(Util.wrapNullable <Guid>(row, SaleReturn.COL_ID), Kontrabons_Id); } } } }
public static bool update(Guid Id, DateTime Timestamp, Guid Customers_Id, string No, decimal Amount, DateTime?ReturnDate, string Notes) { Kontrabon objOld = new Kontrabon(Id); string log = ""; log = Util.appendChange(log, objOld.No, No, "No: '{0}' to '{1}'"); log = Util.appendChange(log, objOld.Timestamp, Timestamp, "Date: '{0:dd/MM/yy}' to '{1:dd/MM/yy}'"); log = Util.appendChange(log, objOld.Amount, Amount, "Amount: '{0}' to '{1}'"); log = Util.appendChange(log, objOld.ReturnDate, ReturnDate, "Return Date: '{0:dd/MM/yy}' to '{1:dd/MM/yy}'"); log = Util.appendChange(log, objOld.Notes, Notes, "Notes: '{0}' to '{1}'"); string newCustomerName = new Customer(Customers_Id).Name; if (objOld.Customers_Name != newCustomerName) { log = Util.appendChange(log, objOld.Customers_Name, newCustomerName, "Customer: '{0}' to '{1}'"); if (!Util.displayMessageBoxYesNo("Sale Invoices and Returns will be removed because customer is changed")) { return(false); } } if (!string.IsNullOrEmpty(log)) { SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "Kontrabons_update", new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, Id), new SqlQueryParameter(COL_DB_Timestamp, SqlDbType.DateTime, Timestamp), new SqlQueryParameter(COL_DB_Customers_Id, SqlDbType.UniqueIdentifier, Customers_Id), new SqlQueryParameter(COL_DB_No, SqlDbType.VarChar, No), new SqlQueryParameter(COL_DB_Amount, SqlDbType.Decimal, Amount), new SqlQueryParameter(COL_DB_ReturnDate, SqlDbType.DateTime, Util.wrapNullable(Util.getAsStartDate(ReturnDate))), new SqlQueryParameter(COL_DB_Notes, SqlDbType.NVarChar, Util.wrapNullable(Notes)) ); if (result.IsSuccessful) { ActivityLog.submit(Id, String.Format("Updated: {0}", log)); } return(result.IsSuccessful); } return(true); }
public static void updateQty(Guid id, decimal value) { SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "SaleOrderItems_update_Qty", new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, id), new SqlQueryParameter(COL_DB_Qty, SqlDbType.Decimal, value) ); if (result.IsSuccessful) { ActivityLog.submit(id, "Qty updated to: " + value); } }
public static void updateCheckedStatus(Guid id, bool value) { SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "SaleReturns_update_Checked", new SqlQueryParameter(COL_ID, SqlDbType.UniqueIdentifier, id), new SqlQueryParameter(COL_Checked, SqlDbType.Bit, value) ); if (result.IsSuccessful) { ActivityLog.submit(id, "Update Checked Status to " + value); } }
public static void updateActive(Guid Id, bool Value) { SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "CustomerTerms_update_Active", new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, Id), new SqlQueryParameter(COL_DB_ACTIVE, SqlDbType.Bit, Value) ); if (result.IsSuccessful) { ActivityLog.submit(Id, "Active changed to: " + Value); } }
public static void updateTargetDate(Guid id, DateTime value) { SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "SaleOrders_update_TargetDate", new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, id), new SqlQueryParameter(COL_DB_TargetDate, SqlDbType.DateTime, value) ); if (result.IsSuccessful) { ActivityLog.submit(id, "Due date updated to: " + value.ToString("dd/MM/yy")); } }
public static void update_Cancelled(Guid Id, bool Value) { SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "VendorInvoicePayments_update_Cancelled", new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, Id), new SqlQueryParameter(COL_DB_Cancelled, SqlDbType.Bit, Value) ); if (result.IsSuccessful) { ActivityLog.submit(Id, String.Format("Cancelled changed to: {0}", Value)); } }
public static void updateStatus(Guid id, ToDoStatus statusEnumID) { SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "todo_update_status", new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, id), new SqlQueryParameter(COL_DB_STATUSENUMID, SqlDbType.TinyInt, statusEnumID) ); if (result.IsSuccessful) { ActivityLog.submit(id, "Update Status to " + statusEnumID.ToString()); } }
public static void update_UsesFakturPajak(Guid Id, bool Value) { SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "customer_update_usesFakturPajak", new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, Id), new SqlQueryParameter(COL_DB_usesFakturPajak, SqlDbType.Bit, Value) ); if (result.IsSuccessful) { ActivityLog.submit(Id, String.Format("Uses Faktur Pajak to: {0}", Value)); } }
public static void updateConfirmedStatus(Guid Id, bool Value) { SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "customercredit_update_Confirmed", new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, Id), new SqlQueryParameter(COL_DB_Confirmed, SqlDbType.Bit, Value) ); if (result.IsSuccessful) { ActivityLog.submit(Id, "Confirmed status changed to: " + Value.ToString().ToLower()); } }