예제 #1
0
        public T FindbyId(int id)
        {
            Costumer costumer = null;

            using (DBClass = new MSSQLDatabase())
            {
                SqlCommand cmd = DBClass.GetStoredProcedureCommand("APP_GET_OUTLET_COSTUMER");
                cmd.Parameters.AddWithValue("@CustId", id);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    costumer             = new Costumer(int.Parse(reader[9].ToString()));
                    costumer.CustId      = int.Parse(reader[0].ToString());
                    costumer.FirstName   = reader[1].ToString();
                    costumer.LastName    = reader[2].ToString();
                    costumer.Address     = reader[3].ToString();
                    costumer.Phone       = reader[4].ToString();
                    costumer.MobilePhone = reader[5].ToString();
                    costumer.Email       = reader[6].ToString();
                    costumer.StatusId    = int.Parse(reader[7].ToString());
                    costumer.Active      = reader[8].ToString() == "True";
                }
            }
            return(costumer as T);
        }
예제 #2
0
        public IEnumerable <Items> GetSalesItems(int salesID)
        {
            var result = new List <Items>();

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("APP_GET_SALES_ITEM_AND_PRESENT") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@SalesId", salesID);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    var item = new Items
                    {
                        SalesID     = salesID,
                        ItemID      = int.Parse(reader[0].ToString()),
                        ProductID   = int.Parse(reader[1].ToString()),
                        ProductCode = reader[2].ToString(),
                        ProductName = reader[3].ToString(),
                        Qty         = decimal.Parse(reader[4].ToString()),
                        Price       = decimal.Parse(reader[5].ToString()),
                        SubTotal    = decimal.Parse(reader[6].ToString()),
                        Keterangan  = reader[7].ToString(),
                        UnitName    = reader[9].ToString(),
                        LogObject   = new StockLogObject
                        {
                            DepartementID = int.Parse(reader[10].ToString()),
                            ProductID     = int.Parse(reader[1].ToString()),
                            SalesVoucher  = reader[11].ToString()
                        }
                    };
                    result.Add(item);
                }
            }
            return(result);
        }
예제 #3
0
        public DataSet[] GetReportData(int salesId, string inWord)
        {
            var     dataSetArray = new DataSet[3];
            DataSet dataSetResult;

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("REPORT_GET_SALES_INVOICE_DATA") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@InvoiceId", salesId);
                DBClass.AddSimpleParameter(cmd, "@InWord", inWord);
                var adapter = new SqlDataAdapter(cmd);
                dataSetResult = new DataSet();
                adapter.Fill(dataSetResult, "SalesInvoiceReport");
                dataSetArray[0] = dataSetResult;
            }
            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("REPORT_GET_SALES_INVOICE_ITEM_AND_PRESENT_DATA") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@InvoiceId", salesId);
                var adapter = new SqlDataAdapter(cmd);
                dataSetResult = new DataSet();
                adapter.Fill(dataSetResult, "SalesInvoiceReportDetail");
                dataSetArray[1] = dataSetResult;
            }
            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("REPORT_GET_SALES_INVOICE_PAYMENTS") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@InvoiceId", salesId);
                var adapter = new SqlDataAdapter(cmd);
                dataSetResult = new DataSet();
                adapter.Fill(dataSetResult, "SalesInvoicePayments");
                dataSetArray[2] = dataSetResult;
            }
            return(dataSetArray);
        }
예제 #4
0
        public override int SaveBankCRUDLog(BankLogObject logObject)
        {
            int objID = 0;

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("SAVE_NEW_BANKFLOW") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@CashBankId", logObject.CashBankID);
                DBClass.AddSimpleParameter(cmd, "@Description", logObject.Description);
                DBClass.AddSimpleParameter(cmd, "@SalesVoucher", logObject.SalesVoucher);
                DBClass.AddSimpleParameter(cmd, "@Deposit", logObject.Deposit);
                DBClass.AddSimpleParameter(cmd, "@Withdraw", logObject.Withdraw);
                DBClass.AddSimpleParameter(cmd, "@Note", logObject.Note);
                DBClass.AddSimpleParameter(cmd, "@CreatedBy", logObject.CreatedBy);
                DBClass.AddSimpleParameter(cmd, "@CreatedDate", logObject.CreatedDate);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    objID = int.Parse(reader[0].ToString());
                }
                if (objID == 0)
                {
                    throw new Exception();
                }
            }
            return(objID);
        }
예제 #5
0
 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;
             }
         }
     }
 }
예제 #6
0
        public IEnumerable <T> FindAll(List <Dictionary <string, object> > keyValueParam)
        {
            var result = new List <Repackage>();

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("APP_GET_ALL_STOCK_REPACKAGE") as SqlCommand;
                RoutinesParameterSetter.Set(ref cmd, keyValueParam);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    var repackage = new Repackage();
                    repackage.RepackageID     = int.Parse(reader[0].ToString());
                    repackage.VoucherCode     = reader[1].ToString();
                    repackage.RepackageDate   = DateTime.Parse(reader[2].ToString());
                    repackage.SourceName      = reader[3].ToString();
                    repackage.SourceQty       = decimal.Parse(reader[4].ToString());
                    repackage.DestinationName = reader[5].ToString();
                    repackage.DestinationQty  = decimal.Parse(reader[6].ToString());
                    repackage.Note            = reader[7].ToString();
                    result.Add(repackage);
                }
            }
            return(result as List <T>);
        }
예제 #7
0
        public IEnumerable <T> FindAll(List <Dictionary <string, object> > keyValueParam)
        {
            var result = new List <Departement>();

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("APP_GET_ALL_DEPARTEMENT") as SqlCommand;
                RoutinesParameterSetter.Set(ref cmd, keyValueParam);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    var departement = new Departement();
                    departement.DepartementID   = int.Parse(reader[0].ToString());
                    departement.DepartementName = reader[1].ToString();
                    departement.CompanyID       = int.Parse(reader[2].ToString());
                    departement.CompanyName     = reader[3].ToString();
                    departement.Address         = reader[4].ToString();
                    departement.Phone           = reader[5].ToString();
                    departement.Head            = reader[6].ToString();
                    departement.WarehouseID     = string.IsNullOrEmpty(reader[7].ToString()) ? (int?)null : int.Parse(reader[7].ToString());
                    departement.WarehouseName   = reader[8].ToString();
                    departement.Active          = bool.Parse(reader[9].ToString());
                    result.Add(departement);
                }
            }
            return(result as List <T>);
        }
예제 #8
0
        public IEnumerable <RequestedItem> GetItemsNeedToBeReceived(int RequestOrderId)
        {
            var result = new List <RequestedItem>();

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("APP_GET_REQUEST_ORDER_NEED_TOBE_RECEIVED") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@RequestOrderId", RequestOrderId);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    var item = new RequestedItem();
                    item.ProductID      = int.Parse(reader[0].ToString());
                    item.RequestOrderID = int.Parse(reader[1].ToString());
                    item.ProductCode    = reader[2].ToString();
                    item.ProductName    = reader[3].ToString();
                    item.Qty            = decimal.Parse(reader[4].ToString());
                    item.IsSent         = bool.Parse(reader[5].ToString());
                    item.IsDelivered    = bool.Parse(reader[6].ToString());
                    item.UnitName       = reader[7].ToString();
                    item.Note           = reader[8].ToString();
                    item.DeliverDate    = DateTime.Parse(reader[9].ToString());
                    result.Add(item);
                }
            }
            return(result);
        }
예제 #9
0
        public IEnumerable <RequestedItem> GetRequestOrderItemHistory(int RequestOrderId)
        {
            var result = new List <RequestedItem>();

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("APP_GET_REQUEST_ORDER_HISTORY") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@RequestOrderId", RequestOrderId);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    var item = new RequestedItem();
                    item.ProductID      = int.Parse(reader[0].ToString());
                    item.RequestOrderID = int.Parse(reader[1].ToString());
                    item.ProductCode    = reader[2].ToString();
                    item.ProductName    = reader[3].ToString();
                    item.Qty            = decimal.Parse(reader[4].ToString());
                    item.DeliverQty     = decimal.Parse(reader[5].ToString());
                    item.Note           = reader[9].ToString();
                    item.DeliverDate    = DateTime.Parse(reader[10].ToString());
                    result.Add(item);
                }
            }
            return(result);
        }
예제 #10
0
        public IEnumerable <T> FindWarehouseDashboardData(List <Dictionary <string, object> > keyValueParam)
        {
            var result = new List <RequestOrder>();

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("APP_GET_ALL_REQUEST_ORDER_WAREHOUSE") as SqlCommand;
                RoutinesParameterSetter.Set(ref cmd, keyValueParam);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    var RequestOrder = new RequestOrder();
                    RequestOrder.RequestOrderID  = int.Parse(reader[0].ToString());
                    RequestOrder.VoucherCode     = reader[1].ToString();
                    RequestOrder.RequestDate     = DateTime.Parse(reader[2].ToString());
                    RequestOrder.WarehouseID     = int.Parse(reader[3].ToString());
                    RequestOrder.WarehouseName   = reader[4].ToString();
                    RequestOrder.DepartementID   = int.Parse(reader[5].ToString());
                    RequestOrder.DepartementName = reader[6].ToString();
                    RequestOrder.Note            = reader[7].ToString();
                    result.Add(RequestOrder);
                }
            }
            return(result as List <T>);
        }
예제 #11
0
        public IEnumerable <RequestedItem> GetRequestedItems(int RequestOrderId)
        {
            var result = new List <RequestedItem>();

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("APP_GET_REQUEST_ORDER_ITEM") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@RequestOrderId", RequestOrderId);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    var item = new RequestedItem
                    {
                        ProductID        = int.Parse(reader[0].ToString()),
                        RequestOrderID   = int.Parse(reader[1].ToString()),
                        ProductCode      = reader[2].ToString(),
                        ProductName      = reader[3].ToString(),
                        Qty              = decimal.Parse(reader[4].ToString()),
                        SentVoucher      = reader[5].ToString(),
                        DeliveredVoucher = reader[6].ToString(),
                        UnitName         = reader[7].ToString()
                    };
                    result.Add(item);
                }
            }
            return(result);
        }
예제 #12
0
        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);
        }
예제 #13
0
        public int SaveRow(T param, string createdBy)
        {
            int objID = 0;

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("APP_SAVE_NEW_REQUEST_ORDER") as SqlCommand;
                RoutinesParameterSetter.Set(ref cmd, param, CRUDType.Insert);
                DBClass.AddSimpleParameter(cmd, "@CreatedBy", createdBy);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    objID = int.Parse(reader[0].ToString());
                }
                var listItems = (param as RequestOrder).Items;
                try
                {
                    foreach (var item in listItems)
                    {
                        SaveRequestedItem(objID, item);
                    }
                }
                catch (Exception)
                {
                    DeleteRow(objID, "System");
                    objID = 0;
                }
            }
            return(objID);
        }
예제 #14
0
        public IEnumerable <T> FindAll(List <Dictionary <string, object> > keyValueParam)
        {
            var result = new List <Costumer>();

            using (DBClass = new MSSQLDatabase())
            {
                SqlCommand cmd = DBClass.GetStoredProcedureCommand("APP_GET_ALL_OUTLET_COSTUMER");
                RoutinesParameterSetter.Set(ref cmd, keyValueParam);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    var costumer = new Costumer(int.Parse(reader[9].ToString()));
                    costumer.CustId      = int.Parse(reader[0].ToString());
                    costumer.FirstName   = reader[1].ToString();
                    costumer.LastName    = reader[2].ToString();
                    costumer.Address     = reader[3].ToString();
                    costumer.Phone       = reader[4].ToString();
                    costumer.MobilePhone = reader[5].ToString();
                    costumer.Email       = reader[6].ToString();
                    costumer.StatusId    = int.Parse(reader[7].ToString());
                    costumer.Active      = reader[8].ToString() == "True";
                    result.Add(costumer);
                }
            }
            return(result as List <T>);
        }
예제 #15
0
        public IList <ProductionResult> GetProductionResults(int productionID)
        {
            var result = new List <ProductionResult>();

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("APP_GET_PRODUCTION_OUTPUTS") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@ProductionId", productionID);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    var item = new ProductionResult
                    {
                        ProductionID = productionID,
                        ProductID    = int.Parse(reader[0].ToString()),
                        ProductCode  = reader[1].ToString(),
                        ProductName  = reader[2].ToString(),
                        Qty          = decimal.Parse(reader[3].ToString()),
                        UnitName     = reader[4].ToString(),
                        LogObject    = new StockLogObject
                        {
                            DepartementID     = int.Parse(reader[5].ToString()),
                            ProductID         = int.Parse(reader[0].ToString()),
                            ProductionVoucher = reader[6].ToString()
                        }
                    };
                    result.Add(item);
                }
            }
            return(result);
        }
예제 #16
0
        public DataSet[] GetReportData(int proformaId)
        {
            DataSet[] dataSetArray = new DataSet[2];
            DataSet   dataSetResult;

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("REPORT_GET_REQUEST_ORDER_DATA") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@RequestOrderId", proformaId);
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                dataSetResult = new DataSet();
                adapter.Fill(dataSetResult, "RequestOrder");
                dataSetArray[0] = dataSetResult;
            }
            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("REPORT_GET_REQUEST_ORDER_ITEM") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@RequestOrderId", proformaId);
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                dataSetResult = new DataSet();
                adapter.Fill(dataSetResult, "RequestOrderItem");
                dataSetArray[1] = dataSetResult;
            }
            return(dataSetArray);
        }
예제 #17
0
        public DataSet[] GetReportData(int productionID)
        {
            DataSet[] dataSetArray = new DataSet[3];
            DataSet   dataSetResult;

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("REPORT_GET_PRODUCTION_DATA") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@ProductionId", productionID);
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                dataSetResult = new DataSet();
                adapter.Fill(dataSetResult, "Production");
                dataSetArray[0] = dataSetResult;
            }
            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("REPORT_GET_PRODUCTION_MATERIAL") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@ProductionId", productionID);
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                dataSetResult = new DataSet();
                adapter.Fill(dataSetResult, "ProductionComposite");
                dataSetArray[1] = dataSetResult;
            }
            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("REPORT_GET_PRODUCTION_OUTPUT") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@ProductionId", productionID);
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                dataSetResult = new DataSet();
                adapter.Fill(dataSetResult, "ProductionResult");
                dataSetArray[2] = dataSetResult;
            }
            return(dataSetArray);
        }
예제 #18
0
        public IEnumerable <T> FindAll(List <Dictionary <string, object> > keyValueParam)
        {
            var result = new List <StockAdjustment>();

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("APP_GET_ALL_STOCK_ADJUSTMENT") as SqlCommand;
                RoutinesParameterSetter.Set(ref cmd, keyValueParam);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    var stockAdjustment = new StockAdjustment
                    {
                        AdjustmentID   = int.Parse(reader[0].ToString()),
                        VoucherCode    = reader[1].ToString(),
                        AdjustmentDate = DateTime.Parse(reader[2].ToString()),
                        ProductCode    = reader[3].ToString(),
                        ProductName    = reader[4].ToString(),
                        AdjustmentType = reader[5].ToString(),
                        Qty            = decimal.Parse(reader[6].ToString()),
                        Note           = reader[7].ToString()
                    };
                    result.Add(stockAdjustment);
                }
            }
            return(result as List <T>);
        }
예제 #19
0
        public T FindbyId(int id)
        {
            var departement = new Departement();

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("APP_GET_DEPARTEMENT_BY_ID") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@DepartementId", id);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    departement.DepartementID   = int.Parse(reader[0].ToString());
                    departement.DepartementName = reader[1].ToString();
                    departement.CompanyID       = int.Parse(reader[2].ToString());
                    departement.CompanyName     = reader[3].ToString();
                    departement.Address         = reader[4].ToString();
                    departement.Phone           = reader[5].ToString();
                    departement.Head            = reader[6].ToString();
                    departement.SupervisorID    = string.IsNullOrEmpty(reader[7].ToString()) ? (int?)null : int.Parse(reader[7].ToString());
                    departement.SupervisorName  = reader[8].ToString();
                    departement.WarehouseID     = string.IsNullOrEmpty(reader[9].ToString()) ? (int?)null : int.Parse(reader[9].ToString());
                    departement.WarehouseName   = reader[10].ToString();
                    departement.IsSupervisor    = bool.Parse(reader[11].ToString());
                    departement.IsTreasurer     = bool.Parse(reader[12].ToString());
                    departement.IsWarehouse     = bool.Parse(reader[13].ToString());
                    departement.IsOutlet        = bool.Parse(reader[14].ToString());
                    departement.Active          = bool.Parse(reader[15].ToString());
                }
            }
            return(departement as T);
        }
예제 #20
0
        public T FindbyId(int id)
        {
            var stockAdjustment = new StockAdjustment();

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("APP_GET_STOCK_ADJUSTEMENT_BY_ID") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@StockAdjustmentId", id);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    stockAdjustment.AdjustmentID   = int.Parse(reader[0].ToString());
                    stockAdjustment.VoucherCode    = reader[1].ToString();
                    stockAdjustment.DepartementId  = int.Parse(reader[2].ToString());
                    stockAdjustment.ProductId      = int.Parse(reader[3].ToString());
                    stockAdjustment.AdjustmentType = reader[4].ToString();
                    stockAdjustment.Qty            = decimal.Parse(reader[5].ToString());
                    stockAdjustment.Note           = reader[6].ToString();
                    stockAdjustment.AdjustmentDate = DateTime.Parse(reader[7].ToString());
                    stockAdjustment.LogObject      = new StockLogObject
                    {
                        DepartementID     = stockAdjustment.DepartementId,
                        ProductID         = stockAdjustment.ProductId,
                        AdjustmentVoucher = stockAdjustment.VoucherCode
                    };
                }
            }
            return(stockAdjustment as T);
        }
예제 #21
0
        public override void DeleteStockCRUDLog(CRUDLogObject logObject)
        {
            var obj = logObject as StockLogObject;

            using (DBClass = new MSSQLDatabase())
            {
                using (DbTransaction txn = DBClass.BeginTransaction())
                {
                    try
                    {
                        var cmd = DBClass.GetStoredProcedureCommand("DELETE_STOCKFLOW") as SqlCommand;
                        DBClass.AddSimpleParameter(cmd, "@ProductId", obj.ProductID);
                        DBClass.AddSimpleParameter(cmd, "@DepartementId", obj.DepartementID);
                        DBClass.AddSimpleParameter(cmd, "@SalesVoucher", obj.SalesVoucher);
                        var affectedRows = DBClass.ExecuteNonQuery(cmd, txn);
                        if (affectedRows == 0)
                        {
                            throw new Exception("Hapus log gagal");
                        }
                        txn.Commit();
                    }
                    catch (Exception)
                    {
                        txn.Rollback();
                        throw;
                    }
                }
            }
        }
예제 #22
0
        public T FindBankExpenseById(int id)
        {
            var Expense = new Expense();

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("APP_GET_BANK_EXPENSE_BY_ID") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@ExpenseId", id);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    Expense.ExpenseID     = int.Parse(reader[0].ToString());
                    Expense.VoucherCode   = reader[1].ToString();
                    Expense.CashBankID    = int.Parse(reader[2].ToString());
                    Expense.DepartementId = int.Parse(reader[3].ToString());
                    Expense.Description   = reader[4].ToString();
                    Expense.Nominal       = decimal.Parse(reader[5].ToString());
                    Expense.Note          = reader[6].ToString();
                    Expense.ExpenseDate   = DateTime.Parse(reader[7].ToString());
                    Expense.BankLogObject = new BankLogObject
                    {
                        CashBankID     = (int)Expense.CashBankID,
                        ExpenseVoucher = Expense.VoucherCode
                    };
                }
            }
            return(Expense as T);
        }
예제 #23
0
 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;
             }
         }
     }
 }
예제 #24
0
        public IEnumerable <T> FindAllCashIncome(List <Dictionary <string, object> > keyValueParam)
        {
            var result = new List <Income>();

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("APP_GET_ALL_CASH_INCOME") as SqlCommand;
                RoutinesParameterSetter.Set(ref cmd, keyValueParam);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    var income = new Income
                    {
                        IncomeID    = int.Parse(reader[0].ToString()),
                        VoucherCode = reader[1].ToString(),
                        IncomeDate  = DateTime.Parse(reader[2].ToString()),
                        Description = reader[3].ToString(),
                        Nominal     = decimal.Parse(reader[4].ToString()),
                        Note        = reader[5].ToString()
                    };
                    result.Add(income);
                }
            }
            return(result as List <T>);
        }
예제 #25
0
        public IEnumerable <SalesInvoice> FindAll(List <Dictionary <string, object> > keyValueParam)
        {
            var result = new List <SalesInvoice>();

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("APP_GET_ALL_SALES") as SqlCommand;
                RoutinesParameterSetter.Set(ref cmd, keyValueParam);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    var salesInvoice = new SalesInvoice
                    {
                        InvoiceID       = int.Parse(reader[0].ToString()),
                        VoucherCode     = reader[1].ToString(),
                        SalesDate       = DateTime.Parse(reader[2].ToString()),
                        CustomerName    = reader[3].ToString(),
                        DepartementName = reader[4].ToString(),
                        MarketingName   = reader[5].ToString(),
                        Note            = reader[6].ToString(),
                        Discount        = decimal.Parse(reader[7].ToString()),
                        Shipping        = decimal.Parse(reader[8].ToString()),
                        GrandTotal      = decimal.Parse(reader[9].ToString())
                    };
                    result.Add(salesInvoice);
                }
            }
            return(result);
        }
예제 #26
0
        public T FindCashIncomeById(int id)
        {
            var income = new Income();

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("APP_GET_CASH_INCOME_BY_ID") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@IncomeId", id);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    income.IncomeID      = int.Parse(reader[0].ToString());
                    income.VoucherCode   = reader[1].ToString();
                    income.CashID        = int.Parse(reader[2].ToString());
                    income.DepartementId = int.Parse(reader[3].ToString());
                    income.Description   = reader[4].ToString();
                    income.Nominal       = decimal.Parse(reader[5].ToString());
                    income.Note          = reader[6].ToString();
                    income.IncomeDate    = DateTime.Parse(reader[7].ToString());
                    income.CashLogObject = new CashLogObject
                    {
                        DepartementID = income.DepartementId,
                        CashID        = (int)income.CashID,
                        IncomeVoucher = income.VoucherCode
                    };
                }
            }
            return(income as T);
        }
예제 #27
0
        public IEnumerable <Payments> GetSalesPayment(int salesID)
        {
            var result = new List <Payments>();

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("APP_GET_SALES_PAYMENT") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@SalesId", salesID);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    var payment = new Payments
                    {
                        PaymentID     = int.Parse(reader[0].ToString()),
                        PaymentType   = int.Parse(reader[1].ToString()),
                        CashLogObject = new CashLogObject
                        {
                            DepartementID = int.Parse(reader[2].ToString()),
                            CashID        = string.IsNullOrEmpty(reader[3].ToString()) ? 0 : int.Parse(reader[3].ToString()),
                            SalesVoucher  = reader[5].ToString(),
                            CreatedDate   = DateTime.Parse(reader[6].ToString())
                        },
                        BankLogObject = new BankLogObject
                        {
                            CashBankID   = string.IsNullOrEmpty(reader[4].ToString()) ? 0 : int.Parse(reader[4].ToString()),
                            SalesVoucher = reader[5].ToString(),
                            CreatedDate  = DateTime.Parse(reader[6].ToString())
                        }
                    };
                    result.Add(payment);
                }
            }
            return(result);
        }
예제 #28
0
        public override int SaveStockCRUDLog(CRUDLogObject logObject)
        {
            var obj   = logObject as StockLogObject;
            int objID = 0;

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("SAVE_NEW_STOCKFLOW") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@DepartementId", obj.DepartementID);
                DBClass.AddSimpleParameter(cmd, "@ProductId", obj.ProductID);
                DBClass.AddSimpleParameter(cmd, "@Description", obj.Description);
                DBClass.AddSimpleParameter(cmd, "@ProductionVoucher", obj.ProductionVoucher);
                DBClass.AddSimpleParameter(cmd, "@Deposit", obj.Deposit);
                DBClass.AddSimpleParameter(cmd, "@Withdraw", obj.Withdraw);
                DBClass.AddSimpleParameter(cmd, "@Note", obj.Note);
                DBClass.AddSimpleParameter(cmd, "@CreatedBy", obj.CreatedBy);
                DBClass.AddSimpleParameter(cmd, "@CreatedDate", obj.CreatedDate);
                var reader = DBClass.ExecuteReader(cmd);
                while (reader.Read())
                {
                    objID = int.Parse(reader[0].ToString());
                }
                if (objID == 0)
                {
                    throw new Exception();
                }
            }
            return(objID);
        }
예제 #29
0
 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;
             }
         }
     }
 }
예제 #30
0
        public DataSet[] GetReportData(int proformaId, string inWord)
        {
            DataSet[] dataSetArray = new DataSet[2];
            DataSet   dataSetResult;

            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("REPORT_GET_PROFORMA_INVOICE_DATA") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@ProformaInvoiceId", proformaId);
                DBClass.AddSimpleParameter(cmd, "@InWord", inWord);
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                dataSetResult = new DataSet();
                adapter.Fill(dataSetResult, "InvoiceReport");
                dataSetArray[0] = dataSetResult;
            }
            using (DBClass = new MSSQLDatabase())
            {
                var cmd = DBClass.GetStoredProcedureCommand("REPORT_GET_PROFORMA_INVOICE_ITEM_AND_PRESENT_DATA") as SqlCommand;
                DBClass.AddSimpleParameter(cmd, "@ProformaInvoiceId", proformaId);
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                dataSetResult = new DataSet();
                adapter.Fill(dataSetResult, "InvoiceReportDetail");
                dataSetArray[1] = dataSetResult;
            }
            return(dataSetArray);
        }