public int UpdateRow(T param, string updatedBy) { var RequestOrder = param as RequestOrder; var result = default(int); using (DBClass = new MSSQLDatabase()) { var cmd = DBClass.GetStoredProcedureCommand("APP_UPDATE_REQUEST_ORDER") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@DepartementId", RequestOrder.DepartementID); DBClass.AddSimpleParameter(cmd, "@WarehouseId", RequestOrder.WarehouseID); DBClass.AddSimpleParameter(cmd, "@RequestDate", RequestOrder.RequestDate); DBClass.AddSimpleParameter(cmd, "@Note", RequestOrder.Note); DBClass.AddSimpleParameter(cmd, "@LastUpdatedBy", updatedBy); DBClass.AddSimpleParameter(cmd, "@RequestOrderId", RequestOrder.RequestOrderID); try { DBClass.ExecuteNonQuery(cmd); var listItems = (param as RequestOrder).Items; foreach (var item in listItems) { SaveRequestedItem(RequestOrder.RequestOrderID, item); } } catch (Exception) { result = 1; } } return(result); }
public int UpdateRow(T param, string updatedBy) { var jobCosting = param as JobCosting; var result = default(int); using (DBClass = new MSSQLDatabase()) { SqlCommand cmd = DBClass.GetStoredProcedureCommand("APP_UPDATE_JOB_COSTING"); cmd.Parameters.AddWithValue("@VoucherCode", jobCosting.VoucherCode); cmd.Parameters.AddWithValue("@DepartementId", jobCosting.DepartementID); cmd.Parameters.AddWithValue("@DestinationProduct", jobCosting.DestinationProduct); cmd.Parameters.AddWithValue("@DestinationQty", jobCosting.DestinationQty); cmd.Parameters.AddWithValue("@DestinationDate", jobCosting.DestinationDate); cmd.Parameters.AddWithValue("@Note", jobCosting.Note); cmd.Parameters.AddWithValue("@LastUpdatedBy", updatedBy); cmd.Parameters.AddWithValue("@JobCostingDate", jobCosting.JobCostingDate); cmd.Parameters.AddWithValue("@JobCostingId", jobCosting.JobCostingID); try { DBClass.ExecuteNonQuery(cmd); var listMaterial = (param as JobCosting).Materials; foreach (var material in listMaterial) { SaveRawMaterial(jobCosting.JobCostingID, material); } } catch (Exception) { result = 1; } } return(result); }
private void SavePurchasedItem(int id, PurchasedItem item) { using (DBClass = new MSSQLDatabase()) { using (DbTransaction txn = DBClass.BeginTransaction()) { try { var cmd = DBClass.GetStoredProcedureCommand("APP_SAVE_NEW_PURCHASE_ORDER_ITEM") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@PurchaseOrderId", id); DBClass.AddSimpleParameter(cmd, "@ProductId", item.ProductID); DBClass.AddSimpleParameter(cmd, "@Qty", item.Qty); DBClass.AddSimpleParameter(cmd, "@EstimatedDate", item.EstimatedDate); DBClass.AddSimpleParameter(cmd, "@DeliveredStatus", 1); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } catch (Exception) { txn.Rollback(); throw; } } } }
private void RefundByBankAccount(int depositSalesId, int bankAccountId, decimal nominal, string note, DateTime refundDate, string createdBy) { using (DBClass = new MSSQLDatabase()) { using (DbTransaction txn = DBClass.BeginTransaction()) { try { var cmd = DBClass.GetStoredProcedureCommand("APP_REFUND_DEPOSIT_SALES_BY_BANK") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@BankAccountId", bankAccountId); DBClass.AddSimpleParameter(cmd, "@DepositSalesId", depositSalesId); DBClass.AddSimpleParameter(cmd, "@Nominal", nominal); DBClass.AddSimpleParameter(cmd, "@Note", note); DBClass.AddSimpleParameter(cmd, "@RefundDate", refundDate); DBClass.AddSimpleParameter(cmd, "@CreatedBy", createdBy); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } catch (Exception) { txn.Rollback(); throw; } } } }
public int UpdateRow(T param, string updatedBy) { var purchaseOrder = param as PurchaseOrder; var result = default(int); using (DBClass = new MSSQLDatabase()) { var cmd = DBClass.GetStoredProcedureCommand("APP_UPDATE_PURCHASE_ORDER") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@DepartementId", purchaseOrder.DepartementID); DBClass.AddSimpleParameter(cmd, "@SupplierId", purchaseOrder.SupplierID); DBClass.AddSimpleParameter(cmd, "@PurchaseDate", purchaseOrder.PurchaseDate); DBClass.AddSimpleParameter(cmd, "@Note", purchaseOrder.Note); DBClass.AddSimpleParameter(cmd, "@LastUpdatedBy", updatedBy); DBClass.AddSimpleParameter(cmd, "@PurchaseOrderId", purchaseOrder.PurchaseOrderID); try { DBClass.ExecuteNonQuery(cmd); var listItems = (param as PurchaseOrder).Items; foreach (var item in listItems) { SavePurchasedItem(purchaseOrder.PurchaseOrderID, item); } } catch (Exception) { result = 1; } } return(result); }
private void SaveRawMaterial(int id, RawMaterial material) { using (DBClass = new MSSQLDatabase()) { using (DbTransaction txn = DBClass.BeginTransaction()) { try { var cmd = DBClass.GetStoredProcedureCommand("APP_SAVE_NEW_JOB_COSTING_MATERIAL"); cmd.Parameters.AddWithValue("@JobCostingId", id); cmd.Parameters.AddWithValue("@ProductId", material.ProductID); cmd.Parameters.AddWithValue("@Qty", material.Qty); cmd.Parameters.AddWithValue("@Type", material.Type); cmd.Parameters.AddWithValue("@MaterialDate", material.Date); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } catch (Exception) { txn.Rollback(); throw; } } } }
private void SaveItem(int id, Items item) { using (DBClass = new MSSQLDatabase()) { using (DbTransaction txn = DBClass.BeginTransaction()) { try { var cmd = DBClass.GetStoredProcedureCommand("APP_SAVE_NEW_SALES_ITEM") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@SalesId", id); DBClass.AddSimpleParameter(cmd, "@DepartementId", item.DepartementID); DBClass.AddSimpleParameter(cmd, "@ProductId", item.ProductID); DBClass.AddSimpleParameter(cmd, "@Qty", item.Qty); DBClass.AddSimpleParameter(cmd, "@Price", item.Price); DBClass.AddSimpleParameter(cmd, "@SubTotal", item.SubTotal); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } catch (Exception) { txn.Rollback(); throw; } } } }
private void SavePayment(int id, Payments payment) { using (DBClass = new MSSQLDatabase()) { using (DbTransaction txn = DBClass.BeginTransaction()) { try { var cmd = DBClass.GetStoredProcedureCommand("APP_SAVE_NEW_SALES_PAYMENT") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@SalesId", id); DBClass.AddSimpleParameter(cmd, "@PaymentType", payment.PaymentType); DBClass.AddSimpleParameter(cmd, "@Nominal", payment.Nominal); DBClass.AddSimpleParameter(cmd, "@PaymentDate", payment.PaymentDate); if (payment.CashBankID != null) { DBClass.AddSimpleParameter(cmd, "@CashBankId", payment.CashBankID); } if (payment.DepositSalesID != null) { DBClass.AddSimpleParameter(cmd, "@DepositId", payment.DepositSalesID); } DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } catch (Exception) { txn.Rollback(); throw; } } } }
public override void DeleteStockCRUDLog(CRUDLogObject logObject) { var obj = logObject as StockLogObject; using (DBClass = new MSSQLDatabase()) { using (var txn = DBClass.BeginTransaction()) { try { var cmd = DBClass.GetStoredProcedureCommand("DELETE_STOCKFLOW_PO") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@ProductId", obj.ProductID); DBClass.AddSimpleParameter(cmd, "@DepartementId", obj.DepartementID); DBClass.AddSimpleParameter(cmd, "@PurchaseVoucher", obj.PurchaseVoucher); DBClass.AddSimpleParameter(cmd, "@CreatedDate", obj.CreatedDate); var affectedRows = DBClass.ExecuteNonQuery(cmd, txn); if (affectedRows == 0) { throw new Exception("Hapus log gagal"); } txn.Commit(); } catch (Exception) { txn.Rollback(); throw; } } } }
public override void DeleteBankCRUDLog(BankLogObject logObject) { using (DBClass = new MSSQLDatabase()) { using (DbTransaction txn = DBClass.BeginTransaction()) { try { var cmd = DBClass.GetStoredProcedureCommand("DELETE_BANKFLOW") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@CashBankId", logObject.CashBankID); DBClass.AddSimpleParameter(cmd, "@SalesVoucher", logObject.SalesVoucher); var affectedRows = DBClass.ExecuteNonQuery(cmd, txn); if (affectedRows == 0) { throw new Exception("Hapus log gagal"); } txn.Commit(); } catch (Exception) { txn.Rollback(); throw; } } } }
public int UpdateCashIncomeRow(T param, string updatedBy) { using (DBClass = new MSSQLDatabase()) { using (DbTransaction txn = DBClass.BeginTransaction()) { var cmd = DBClass.GetStoredProcedureCommand("APP_UPDATE_INCOME_BY_CASH") as SqlCommand; RoutinesParameterSetter.Set(ref cmd, param, CRUDType.Update); DBClass.AddSimpleParameter(cmd, "@LastUpdatedBy", updatedBy); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } } return(0); }
public int UpdateRow(T param, string updatedBy) { using (DBClass = new MSSQLDatabase()) { using (DbTransaction txn = DBClass.BeginTransaction()) { var cmd = DBClass.GetStoredProcedureCommand("dbo.APP_UPDATE_CUSTOMER") as SqlCommand; RoutinesParameterSetter.Set(ref cmd, param, CRUDType.Update); DBClass.AddSimpleParameter(cmd, "@LastUpdatedBy", updatedBy); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } } /* bypass compiler error need to be updated soon */ return(0); }
public void PaidWithDepositSales(List <Dictionary <string, object> > keyValueParam) { using (DBClass = new MSSQLDatabase()) { using (DbTransaction txn = DBClass.BeginTransaction()) { try { var cmd = DBClass.GetStoredProcedureCommand("PAID_WITH_DEPOSIT_SALES") as SqlCommand; RoutinesParameterSetter.Set(ref cmd, keyValueParam); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } catch (Exception) { } } } }
private void DeleteItemAndPresent(int id) { using (DBClass = new MSSQLDatabase()) { using (DbTransaction txn = DBClass.BeginTransaction()) { try { var cmd = DBClass.GetStoredProcedureCommand("APP_DELETE_PROFORMA_SALES_ITEM_AND_PRESENT") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@ProformaId", id); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } catch (Exception) { txn.Rollback(); throw; } } } }
private void SaveSalesCredit(int id, decimal grandTotal, DateTime creditDate) { using (DBClass = new MSSQLDatabase()) { using (DbTransaction txn = DBClass.BeginTransaction()) { try { var cmd = DBClass.GetStoredProcedureCommand("APP_SAVE_NEW_SALES_CREDIT") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@SalesId", id); DBClass.AddSimpleParameter(cmd, "@GrandTotal", grandTotal); DBClass.AddSimpleParameter(cmd, "@CreditDate", creditDate); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } catch (Exception) { txn.Rollback(); throw; } } } }
private void SaveRequestedItem(int id, RequestedItem item) { using (DBClass = new MSSQLDatabase()) { using (DbTransaction txn = DBClass.BeginTransaction()) { try { var cmd = DBClass.GetStoredProcedureCommand("APP_SAVE_NEW_REQUEST_ORDER_ITEM") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@RequestOrderId", id); DBClass.AddSimpleParameter(cmd, "@ProductId", item.ProductID); DBClass.AddSimpleParameter(cmd, "@Qty", item.Qty); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } catch (Exception) { txn.Rollback(); throw; } } } }
public int DeleteRequestOrderOut(int RequestOrderOutId) { int result = 0; try { using (DBClass = new MSSQLDatabase()) { using (var txn = (SqlTransaction)DBClass.BeginTransaction()) { var cmd = DBClass.GetStoredProcedureCommand("APP_DELETE_REQUEST_ORDER_ITEM_OUT") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@RequestOrderOutId", RequestOrderOutId); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } } } catch (Exception) { result = 1; } return(result); }
private void SaveResult(int id, ProductionResult result) { using (DBClass = new MSSQLDatabase()) { using (DbTransaction txn = DBClass.BeginTransaction()) { try { var cmd = DBClass.GetStoredProcedureCommand("APP_SAVE_NEW_PRODUCTION_OUTPUT") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@ProductionId", id); DBClass.AddSimpleParameter(cmd, "@ProductId", result.ProductID); DBClass.AddSimpleParameter(cmd, "@Qty", result.Qty); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } catch (Exception) { txn.Rollback(); throw; } } } }
public int DeletePurchaseOrderIn(int purchaseOrderInId) { int result = 0; try { using (DBClass = new MSSQLDatabase()) { using (var txn = (SqlTransaction)DBClass.BeginTransaction()) { var cmd = DBClass.GetStoredProcedureCommand("APP_DELETE_PURCHASE_ORDER_ITEM_IN") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@PurchaseOrderInId", purchaseOrderInId); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } } } catch (Exception) { result = 1; } return(result); }
private void SavePresent(int id, Items item) { using (DBClass = new MSSQLDatabase()) { using (DbTransaction txn = DBClass.BeginTransaction()) { try { var cmd = DBClass.GetStoredProcedureCommand("APP_SAVE_NEW_PROFORMA_PRESENT") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@ProformaId", id); DBClass.AddSimpleParameter(cmd, "@ProductId", item.ProductID); DBClass.AddSimpleParameter(cmd, "@Qty", item.Qty); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } catch (Exception) { txn.Rollback(); throw; } } } }
public void SaveEDCPayment(CreditPayment payment, string createdBy) { using (DBClass = new MSSQLDatabase()) { using (DbTransaction txn = DBClass.BeginTransaction()) { try { var cmd = DBClass.GetStoredProcedureCommand("APP_EDC_CREDIT_PAYMENT") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@SalesCreditId", payment.SalesCreditID); DBClass.AddSimpleParameter(cmd, "@CreatedBy", createdBy); DBClass.AddSimpleParameter(cmd, "@PaymentDate", payment.CreditPaymentDate); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } catch (Exception) { txn.Rollback(); throw; } } } }
public int DeleteSalesCreditPayment(int creditPaymentID) { int result = 0; try { using (DBClass = new MSSQLDatabase()) { using (var txn = (SqlTransaction)DBClass.BeginTransaction()) { var cmd = DBClass.GetStoredProcedureCommand("APP_DELETE_SALES_CREDIT_PAYMENT") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@SalesCreditPaymentId", creditPaymentID); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } } } catch (Exception) { result = 1; } return(result); }
public int UpdateRow(T param, string updatedBy) { var production = param as Production; var errorFlag = default(int); using (DBClass = new MSSQLDatabase()) { var cmd = DBClass.GetStoredProcedureCommand("APP_UPDATE_PRODUCTION") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@VoucherCode", production.VoucherCode); DBClass.AddSimpleParameter(cmd, "@DepartementId", production.DepartementID); DBClass.AddSimpleParameter(cmd, "@Note", production.Note); DBClass.AddSimpleParameter(cmd, "@LastUpdatedBy", updatedBy); DBClass.AddSimpleParameter(cmd, "@ProductionDate", production.ProductionDate); DBClass.AddSimpleParameter(cmd, "@ProductionId", production.ProductionID); try { DBClass.ExecuteNonQuery(cmd); var composites = (param as Production).Composites; var results = (param as Production).Results; foreach (var composite in composites) { SaveComposite(production.ProductionID, composite); SaveStockCRUDLog(composite.LogObject); } foreach (var productionResult in results) { SaveResult(production.ProductionID, productionResult); SaveStockCRUDLog(productionResult.LogObject); } } catch (Exception) { errorFlag = 1; } } return(errorFlag); }
public void SavePayment(CreditPayment payment, string createdBy) { using (DBClass = new MSSQLDatabase()) { using (DbTransaction txn = DBClass.BeginTransaction()) { try { var cmd = DBClass.GetStoredProcedureCommand("APP_SAVE_NEW_SALES_CREDIT_PAYMENT") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@SalesCreditId", payment.SalesCreditID); DBClass.AddSimpleParameter(cmd, "@SalesId", payment.SalesId); DBClass.AddSimpleParameter(cmd, "@VoucherCode", payment.VoucherCode); DBClass.AddSimpleParameter(cmd, "@PaymentType", payment.CreditPaymentType); DBClass.AddSimpleParameter(cmd, "@Nominal", payment.Nominal); DBClass.AddSimpleParameter(cmd, "@Note", payment.Note); DBClass.AddSimpleParameter(cmd, "@PaymentDate", payment.CreditPaymentDate); if (payment.CashBankID != null) { DBClass.AddSimpleParameter(cmd, "@CashBankId", payment.CashBankID); } if (payment.DepositSalesID != null) { DBClass.AddSimpleParameter(cmd, "@DepositSalesId", payment.DepositSalesID); } DBClass.AddSimpleParameter(cmd, "@CreatedBy", createdBy); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } catch (Exception) { txn.Rollback(); throw; } } } }
public int DeleteRow(int id, string updatedBy) { int result = 0; try { using (DBClass = new MSSQLDatabase()) { using (var txn = (SqlTransaction)DBClass.BeginTransaction()) { var cmd = DBClass.GetStoredProcedureCommand("dbo.APP_DELETE_CUSTOMER") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@CustomerId", id); DBClass.AddSimpleParameter(cmd, "@LastUpdatedBy", updatedBy); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } } } catch (Exception) { result = 1; } return(result); }
public int DeleteProductionOutputItem(int productionID, int productID) { int result = 0; try { using (DBClass = new MSSQLDatabase()) { using (var txn = (SqlTransaction)DBClass.BeginTransaction()) { var cmd = DBClass.GetStoredProcedureCommand("APP_DELETE_PRODUCTION_OUTPUT_ITEM") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@ProductionId", productionID); DBClass.AddSimpleParameter(cmd, "@ProductId", productID); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } } } catch (Exception) { result = 1; } return(result); }
public int DeleteRow(int id, string updatedBy) { int result = 0; try { using (DBClass = new MSSQLDatabase()) { using (var txn = (SqlTransaction)DBClass.BeginTransaction()) { var cmd = DBClass.GetStoredProcedureCommand("APP_DELETE_JOB_COSTING"); cmd.Parameters.AddWithValue("@JobCostingId", id); cmd.Parameters.AddWithValue("@LastUpdatedBy", updatedBy); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } } } catch (Exception) { result = 1; } return(result); }
private void SaveComposite(int id, Composite composite) { using (DBClass = new MSSQLDatabase()) { using (DbTransaction txn = DBClass.BeginTransaction()) { try { var cmd = DBClass.GetStoredProcedureCommand("APP_SAVE_NEW_PRODUCTION_MATERIAL") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@ProductionId", id); DBClass.AddSimpleParameter(cmd, "@ProductId", composite.ProductID); DBClass.AddSimpleParameter(cmd, "@Qty", composite.Qty); DBClass.AddSimpleParameter(cmd, "@Type", composite.CompositeType); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } catch (Exception) { txn.Rollback(); throw; } } } }
public int DeleteSalesItemPresent(int salesID, int productID) { int result = 0; try { using (DBClass = new MSSQLDatabase()) { using (var txn = (SqlTransaction)DBClass.BeginTransaction()) { var cmd = DBClass.GetStoredProcedureCommand("APP_DELETE_SALES_ITEM_PRESENT") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@SalesId", salesID); DBClass.AddSimpleParameter(cmd, "@ProductId", productID); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } } } catch (Exception) { result = 1; } return(result); }
public string LockUser(string userName) { string result; try { using (DBClass = new MSSQLDatabase()) { using (var txn = DBClass.BeginTransaction()) { var cmd = DBClass.GetStoredProcedureCommand("LockUser") as SqlCommand; DBClass.AddSimpleParameter(cmd, "@Username", userName); DBClass.ExecuteNonQuery(cmd, txn); txn.Commit(); } } result = "User telah di non-aktifkan!"; } catch (Exception e) { result = e.Message; } return(result); }