Exemple #1
0
        private void SaveTransactionDetail()
        {
            TTransactionDetail det;
            MItem item;

            for (int i = 0; i < tTransactionDetailDataGridView.Rows.Count; i++)
            {
                item = (MItem)DataMaster.GetObjectByProperty(typeof(MItem), MItem.ColumnNames.ItemId, tTransactionDetailDataGridView.Rows[i].Cells[0].Value.ToString());
                decimal qty = Convert.ToDecimal(tTransactionDetailDataGridView.Rows[i].Cells[2].Value);

                det = new TTransactionDetail();

                if (item != null)
                {
                    det.CostPrice = qty * item.ItemPricePurchaseAvg;
                }

                det.Description = tTransactionDetailDataGridView.Rows[i].Cells[7].Value.ToString();
                det.ItemId      = tTransactionDetailDataGridView.Rows[i].Cells[0].Value.ToString();
                det.Jumlah      = Convert.ToDecimal(tTransactionDetailDataGridView.Rows[i].Cells[4].Value);
                det.Disc        = Convert.ToDecimal(tTransactionDetailDataGridView.Rows[i].Cells[5].Value);
                det.Ppn         = 0;
                det.Price       = Convert.ToDecimal(tTransactionDetailDataGridView.Rows[i].Cells[3].Value);
                det.Quantity    = qty;

                det.Total = Convert.ToDecimal(tTransactionDetailDataGridView.Rows[i].Cells[6].Value);

                det.TransactionId = decimal.Parse(transactionIdLabel.Text);

                det.ModifiedBy   = lbl_UserName.Text;
                det.ModifiedDate = DateTime.Now;
                DataMaster.SavePersistence(det);
            }
        }
        private void SaveTransactionDetail()
        {
            for (int i = 0; i < tTransactionDetailDataGridView.RowCount; i++)
            {
                TTransactionDetail det = new TTransactionDetail();
                det.ItemId   = tTransactionDetailDataGridView.Rows[i].Cells[0].Value.ToString();
                det.Quantity = Convert.ToDecimal(tTransactionDetailDataGridView.Rows[i].Cells[1].Value);
                DataMaster.SaveOrUpdate(det);

                UpdateStok(det.ItemId, det.Quantity);
            }
        }
Exemple #3
0
        private void SaveTransactionDetail()
        {
            TTransactionDetail det;
            ItemGudangStok     stok;
            MItem     item;
            TStokCard krt;

            int gudangId = 1;

            bool    AddStok = true;
            decimal saldo   = 0;

            if ((trans == ListOfTransaction.Sales) || (trans == ListOfTransaction.ReturPurchase))
            {
                AddStok = false;
            }
            else if ((trans == ListOfTransaction.Purchase) || (trans == ListOfTransaction.ReturSales))
            {
                AddStok = true;
            }

            for (int i = 0; i < tTransactionDetailDataGridView.Rows.Count; i++)
            {
                saldo = 0;

                det             = new TTransactionDetail();
                det.Description = string.Empty;
                det.Disc        = Convert.ToDecimal(tTransactionDetailDataGridView.Rows[i].Cells[5].Value);
                det.ExpiredDate = Convert.ToDateTime(tTransactionDetailDataGridView.Rows[i].Cells[8].Value);
                det.ItemId      = tTransactionDetailDataGridView.Rows[i].Cells[0].Value.ToString();
                det.Jumlah      = Convert.ToDecimal(tTransactionDetailDataGridView.Rows[i].Cells[4].Value);
                det.Ppn         = 0;
                det.Price       = Convert.ToDecimal(tTransactionDetailDataGridView.Rows[i].Cells[3].Value);
                det.Quantity    = Convert.ToDecimal(tTransactionDetailDataGridView.Rows[i].Cells[2].Value);

                //if corection, save item quantity for detail total
                if (trans == ListOfTransaction.Correction)
                {
                    det.Total = Convert.ToDecimal(tTransactionDetailDataGridView.Rows[i].Cells[2].Value);
                }
                else
                {
                    det.Total = Convert.ToDecimal(tTransactionDetailDataGridView.Rows[i].Cells[7].Value);
                }

                det.TransactionId = Convert.ToDecimal(transactionIdLabel.Text);
                det.Tuslah        = Convert.ToDecimal(tTransactionDetailDataGridView.Rows[i].Cells[6].Value);
                det.ModifiedBy    = lbl_UserName.Text;
                det.ModifiedDate  = DateTime.Now;
                DataMaster.SavePersistence(det);

                item = (MItem)DataMaster.GetObjectByProperty(typeof(MItem), MItem.ColumnNames.ItemId, tTransactionDetailDataGridView.Rows[i].Cells[0].Value.ToString());
                if (item != null)
                {
                    //if purchase, update item price avg
                    if (trans == ListOfTransaction.Purchase)
                    {
                        item.ItemPricePurchaseAvg = (item.ItemPricePurchaseAvg + Convert.ToDecimal(tTransactionDetailDataGridView.Rows[i].Cells[3].Value)) / 2;
                        DataMaster.UpdatePersistence(item);
                    }

                    //if item == barang
                    if (item.ItemTypeId == 1)
                    {
                        //change stok
                        stok = (ItemGudangStok)DataMaster.GetObjectByProperty(typeof(ItemGudangStok), ItemGudangStok.ColumnNames.ItemId, tTransactionDetailDataGridView.Rows[i].Cells[0].Value.ToString(), ItemGudangStok.ColumnNames.GudangId, gudangId);
                        if (stok != null)
                        {
                            if (AddStok)
                            {
                                saldo = stok.ItemStok + Convert.ToDecimal(tTransactionDetailDataGridView.Rows[i].Cells[2].Value);
                            }
                            else
                            {
                                saldo = stok.ItemStok - Convert.ToDecimal(tTransactionDetailDataGridView.Rows[i].Cells[2].Value);
                            }

                            stok.ItemStok     = saldo;
                            stok.ModifiedBy   = lbl_UserName.Text;
                            stok.ModifiedDate = DateTime.Now;
                            DataMaster.UpdatePersistence(stok);
                        }
                        else
                        {
                            stok             = new ItemGudangStok();
                            stok.GudangId    = gudangId;
                            stok.ItemId      = det.ItemId;
                            stok.ItemMaxStok = 0;
                            stok.ItemMinStok = 0;
                            if (AddStok)
                            {
                                stok.ItemStok = det.Quantity;
                            }
                            else
                            {
                                stok.ItemStok = det.Quantity * -1;
                            }
                            stok.ModifiedBy   = lbl_UserName.Text;
                            stok.ModifiedDate = DateTime.Now;
                            DataMaster.SavePersistence(stok);
                        }
                    }

                    krt                  = new TStokCard();
                    krt.ItemId           = tTransactionDetailDataGridView.Rows[i].Cells[0].Value.ToString();
                    krt.GudangId         = gudangId;
                    krt.StokCardDate     = DateTime.Now;
                    krt.StokCardPic      = lbl_UserName.Text;
                    krt.StokCardQuantity = Convert.ToDecimal(tTransactionDetailDataGridView.Rows[i].Cells[2].Value);
                    krt.StokCardSaldo    = saldo;
                    krt.StokCardStatus   = AddStok;
                    krt.TransactionId    = Convert.ToDecimal(transactionIdLabel.Text);
                    krt.ModifiedBy       = lbl_UserName.Text;
                    krt.ModifiedDate     = DateTime.Now;
                    DataMaster.SavePersistence(krt);
                }
            }
        }
Exemple #4
0
        private void SaveTransactionDetail()
        {
            TTransactionDetail det;
            ItemGudangStok     stok;
            MItem     item;
            TStokCard krt;


            //clear data if from billiard desk
            if (!lbl_TempDesk.Text.Equals(ListOfDesk.Cafe.ToString()))
            {
                IList listOfTransDetail = DataMaster.GetListEq(typeof(TTransactionDetail), TTransactionDetail.ColumnNames.TransactionId, Convert.ToDecimal(txt_TransactionId.Text));
                for (int i = 0; i < listOfTransDetail.Count; i++)
                {
                    det = (TTransactionDetail)listOfTransDetail[i];
                    DataMaster.Delete(det);
                }

                TDesk t = (TDesk)DataMaster.GetObjectByProperty(typeof(TDesk), TDesk.ColumnNames.DeskTransactionId, Convert.ToDecimal(txt_TransactionId.Text));
                if (t != null)
                {
                    t.DeskStatus   = ListOfBilliardPaymentStatus.Paid.ToString();
                    t.ModifiedBy   = lbl_UserName.Text;
                    t.ModifiedDate = DateTime.Now;
                    DataMaster.UpdatePersistence(t);
                }
            }

            bool    AddStok = true;
            decimal saldo   = 0;

            if (lbl_TempTransaction.Text.Equals(ListOfTransaction.Sales.ToString()) || lbl_TempTransaction.Text.Equals(ListOfTransaction.ReturPurchase.ToString()) || lbl_TempTransaction.Text.Equals(ListOfTransaction.SalesVIP.ToString()))
            {
                AddStok = false;
            }
            else
            {
                AddStok = true;
            }

            for (int i = 0; i < grid_Trans.Rows.Count; i++)
            {
                saldo = 0;

                det          = new TTransactionDetail();
                det.Disc     = Convert.ToDecimal(grid_Trans.Rows[i].Cells[5].Value);
                det.ItemId   = grid_Trans.Rows[i].Cells[0].Value.ToString();
                det.Ppn      = 0;
                det.Price    = Convert.ToDecimal(grid_Trans.Rows[i].Cells[3].Value);
                det.Quantity = Convert.ToDecimal(grid_Trans.Rows[i].Cells[2].Value);

                //if corection, save item quantity for detail total
                if (lbl_TempTransaction.Text.Equals(ListOfTransaction.Correction.ToString()))
                {
                    det.Total = Convert.ToDecimal(grid_Trans.Rows[i].Cells[2].Value);
                }
                else
                {
                    det.Total = Convert.ToDecimal(grid_Trans.Rows[i].Cells[6].Value);
                }

                det.TransactionId = Convert.ToDecimal(txt_TransactionId.Text);
                det.Jumlah        = Convert.ToDecimal(grid_Trans.Rows[i].Cells[4].Value);

                det.ModifiedBy   = lbl_UserName.Text;
                det.ModifiedDate = DateTime.Now;
                DataMaster.SavePersistence(det);

                item = (MItem)DataMaster.GetObjectByProperty(typeof(MItem), MItem.ColumnNames.ItemId, grid_Trans.Rows[i].Cells[0].Value.ToString());
                if (item != null)
                {
                    //if item == barang
                    if (item.ItemTypeId == 1)
                    {
                        //change stok
                        stok = (ItemGudangStok)DataMaster.GetObjectByProperty(typeof(ItemGudangStok), ItemGudangStok.ColumnNames.ItemId, grid_Trans.Rows[i].Cells[0].Value.ToString());
                        if (stok != null)
                        {
                            if (AddStok)
                            {
                                saldo = stok.ItemStok + Convert.ToDecimal(grid_Trans.Rows[i].Cells[2].Value);
                            }
                            else
                            {
                                saldo = stok.ItemStok - Convert.ToDecimal(grid_Trans.Rows[i].Cells[2].Value);
                            }

                            stok.ItemStok     = saldo;
                            stok.ModifiedBy   = lbl_UserName.Text;
                            stok.ModifiedDate = DateTime.Now;
                            DataMaster.UpdatePersistence(stok);
                        }
                        else
                        {
                            stok             = new ItemGudangStok();
                            stok.GudangId    = 1;
                            stok.ItemId      = det.ItemId;
                            stok.ItemMaxStok = 0;
                            stok.ItemMinStok = 0;
                            if (AddStok)
                            {
                                stok.ItemStok = det.Quantity;
                            }
                            else
                            {
                                stok.ItemStok = det.Quantity * -1;
                            }
                            stok.ModifiedBy   = lbl_UserName.Text;
                            stok.ModifiedDate = DateTime.Now;
                            DataMaster.SavePersistence(stok);
                        }
                    }
                }

                krt                  = new TStokCard();
                krt.ItemId           = grid_Trans.Rows[i].Cells[0].Value.ToString();
                krt.StokCardDate     = DateTime.Now;
                krt.StokCardPic      = lbl_UserName.Text;
                krt.StokCardQuantity = Convert.ToDecimal(grid_Trans.Rows[i].Cells[2].Value);
                krt.StokCardSaldo    = saldo;
                krt.StokCardStatus   = AddStok;
                krt.TransactionId    = Convert.ToDecimal(txt_TransactionId.Text);
                krt.ModifiedBy       = lbl_UserName.Text;
                krt.ModifiedDate     = DateTime.Now;
                DataMaster.SavePersistence(krt);
            }
        }