Beispiel #1
0
        private void CmdOK_Click(object sender, EventArgs e)
        {
            // Saving / updating the master table into the database
            if (FormMode == "New")
            {
                SaveToDb();
            }
            else
            {
                clsLogs Dlogs = new clsLogs
                {
                    TransferReference = Convert.ToInt32(TxtTransferID.Text),
                    MovementDate      = oldDate,
                    MovementType      = 2
                };  // Delete old StockMovements details for current transfer
                Dlogs.DeleteFromStockMovemmentsTable();
                UpdateToDb();
            }

            this.Close();
        }
        private void CmdOK_Click(object sender, EventArgs e)
        {
            clsShopTransferHead transferHead = new clsShopTransferHead();
            clsShopTransferLine transferLine = new clsShopTransferLine();

            int SavedID = 0;

            transferHead.ShopRef      = TxtFromShopRef.Text.TrimEnd();
            transferHead.ShopName     = txtFromShopName.Text.TrimEnd();
            transferHead.ToShopName   = txtToShopName.Text.TrimEnd();
            transferHead.ToShopRef    = TxtToShopRef.Text.TrimEnd();
            transferHead.MovementDate = Convert.ToDateTime(DtpDate.Value);
            transferHead.Qty          = Convert.ToInt32(txtTotalTransferTo.Text.TrimEnd());
            transferHead.UserID       = LogggedInUser;
            transferHead.Reference    = TxtTFNote.Text.TrimEnd();
            // Saving / updating the master table into the database
            if (FormMode == "New")
            {
                transferHead.SaveShopTransferHead();
                SavedID = transferHead.GetLastShopTransferHead();
            }
            else
            {
                clsLogs Dlogs = new clsLogs();  // Delete old StockMovements details for current transfer
                Dlogs.TransferReference = SavedID;
                Dlogs.MovementDate      = olddate;
                Dlogs.MovementType      = 2;
                Dlogs.DeleteFromStockMovemmentsTable();
                transferHead.ShopTransferID = Convert.ToInt32(TxtTransferID.Text.TrimEnd());
                transferHead.UpdateShopTransferHead();
            }

            clsLogs logs = new clsLogs();

            logs.TransferReference      = SavedID;
            transferLine.ShopTransferID = SavedID;
            logs.MovementDate           = transferHead.MovementDate;
            logs.LocationType           = 2;
            logs.MovementType           = 4;
            logs.DeliveredQtyGarments   = 0;
            logs.DeliveredQtyBoxes      = 0;
            logs.SupplierRef            = "N/A";
            logs.Reference          = transferHead.Reference;
            logs.UserID             = transferHead.UserID;
            logs.StringMovementType = "WarehouseTransfer";
            logs.RecordType         = "WarehouseTransfer-Item";
            for (int index = 0; index < DgvRecords.Rows.Count; index++)
            {
                transferLine.StockCode = DgvRecords.Rows[index].Cells[0].Value.ToString();
                logs.StockCode         = transferLine.StockCode;
                transferLine.CurrQty   = Convert.ToInt32(DgvRecords.Rows[index].Cells[1].Value);
                transferLine.TOQty     = Convert.ToInt32(DgvRecords.Rows[index].Cells[2].Value) * -1;
                transferLine.TIQty     = Convert.ToInt32(DgvRecords.Rows[index].Cells[2].Value);
                if (FormMode == "New")
                {
                    logs.LocationRef         = transferHead.ShopRef;
                    logs.Qty                 = transferLine.TOQty;
                    logs.DeliveredQtyHangers = logs.Qty;
                    logs.SaveToSysLogTable();
                    logs.SaveToStockMovementsTable();
                    transferLine.SaveShopTransferLine();
                    logs.LocationRef         = transferHead.ToShopRef;
                    logs.Qty                 = transferLine.TIQty;
                    logs.DeliveredQtyHangers = logs.Qty;
                    logs.SaveToSysLogTable();
                    logs.SaveToStockMovementsTable();
                }
                else
                {
                    logs.Qty = transferLine.TOQty;
                    logs.DeliveredQtyHangers = logs.Qty;
                    logs.SaveToSysLogTable();
                    logs.SaveToStockMovementsTable();
                    transferLine.UpdateShopTransferLine();
                    logs.Qty = transferLine.TIQty;
                    logs.DeliveredQtyHangers = logs.Qty;
                    logs.SaveToSysLogTable();
                    logs.SaveToStockMovementsTable();
                }
            }
            this.Close();
        }
        private void cmdOK_Click(object sender, EventArgs e)
        {
            clsShopReturnHead returnHead = new clsShopReturnHead();
            clsShopReturnLine returnLine = new clsShopReturnLine();
            clsLogs           logs       = new clsLogs();
            int SavedID = 0;

            // Header of both adjustments and log file
            returnHead.WarehouseRef = txtWarehouseRef.Text.TrimEnd();
            returnHead.Reference    = txtReference.Text.TrimEnd();
            returnHead.ShopRef      = txtShopRef.Text.TrimEnd();
            returnHead.TotalItems   = Convert.ToInt32(txtTotalItems.Text.TrimEnd());
            returnHead.MovementDate = Convert.ToDateTime(DtpDate.Value);
            returnHead.UserID       = LoggedInUser;
            if (FormMode == "New")
            {
                returnHead.SaveShopReturnHead();
                SavedID = returnHead.GetLastShopReturnHead();
            }
            else
            {
                clsLogs Dlogs = new clsLogs();  // Delete old StockMovements Data from Table
                Dlogs.TransferReference = Convert.ToInt32(txtReturnID.Text.TrimEnd());
                Dlogs.MovementDate      = oldDate;
                Dlogs.MovementType      = 9;
                Dlogs.DeleteFromStockMovemmentsTable();
                returnHead.ShopReturnID = Convert.ToInt32(txtReturnID.Text.TrimEnd());
                returnHead.UpdateShopReturnHead();
            }
            logs.TransferReference  = SavedID;
            returnLine.ShopReturnID = SavedID;
            logs.MovementDate       = returnHead.MovementDate;
            logs.UserID             = returnHead.UserID;
            logs.MovementType       = 8;
            logs.StringMovementType = "Shop Return Item";
            for (int index = 0; index < DgvRecords.Rows.Count; index++)
            {
                logs.LocationRef     = returnHead.WarehouseRef;
                returnLine.StockCode = DgvRecords.Rows[index].Cells[0].Value.ToString();
                returnLine.Qty       = Convert.ToInt32(DgvRecords.Rows[index].Cells[1].Value);
                logs.StockCode       = returnLine.StockCode;
                logs.RecordType      = "Shop Return";
                logs.Reference       = logs.StringMovementType;
                logs.SupplierRef     = "N/A";
                if (FormMode == "New")
                {
                    logs.LocationType        = 2;
                    logs.LocationRef         = returnHead.ShopRef;
                    logs.Qty                 = returnLine.Qty * -1;
                    logs.DeliveredQtyHangers = returnLine.Qty * -1;
                    logs.SaveToSysLogTable();
                    logs.SaveToStockMovementsTable();
                    returnLine.SaveShopReturnLine();
                    logs.LocationRef         = returnHead.WarehouseRef;
                    logs.LocationType        = 1;
                    logs.Qty                 = returnLine.Qty;
                    logs.DeliveredQtyHangers = returnLine.Qty;
                    logs.SaveToSysLogTable();
                    logs.SaveToStockMovementsTable();
                }
                else
                {
                    logs.LocationRef         = returnHead.ShopRef;
                    logs.Qty                 = returnLine.Qty * -1;
                    logs.DeliveredQtyHangers = logs.Qty;
                    logs.SaveToSysLogTable();
                    logs.SaveToStockMovementsTable();
                    returnLine.UpdateShopReturnLine();
                    logs.LocationRef         = returnHead.WarehouseRef;
                    logs.Qty                 = returnLine.Qty;
                    logs.DeliveredQtyHangers = logs.Qty;
                    logs.SaveToSysLogTable();
                    logs.SaveToStockMovementsTable();
                }
            }
            Close();
        }
Beispiel #4
0
        private void UpdateToDb()
        {
            clsWarehouseAdjustmentHead adjustmentHead = new clsWarehouseAdjustmentHead();
            clsLogs logs = new clsLogs();  // Delete old StockMovements Data from Table

            logs.TransferReference = Convert.ToInt32(TxtRecordID.Text.TrimEnd());
            // Header of both adjustments and log file
            adjustmentHead.WarehouseRef   = TxtWarehouseRef.Text.TrimEnd();
            adjustmentHead.Reference      = TxtReference.Text.TrimEnd();
            adjustmentHead.TotalGainItems = Convert.ToInt32(TxtTotalGain.Text.TrimEnd());
            adjustmentHead.TotalLossItems = Convert.ToInt32(TxtTotalLoss.Text.TrimEnd());
            adjustmentHead.MovementDate   = Convert.ToDateTime(DateTimePicker1.Value);
            logs.MovementDate             = olddate;
            logs.MovementType             = 6;
            logs.DeleteFromStockMovemmentsTable();
            logs.MovementType = 7;
            logs.DeleteFromStockMovemmentsTable();
            adjustmentHead.WarehouseAdjustmentID = Convert.ToInt32(TxtRecordID.Text.TrimEnd());
            adjustmentHead.UpdateWarehouseAdjustmentHead();
            clsWarehouseAdjustmentLine adjustmentLine = new clsWarehouseAdjustmentLine();

            // Save To system Log and StockMovements Table
            adjustmentLine.WarehouseAdjustmentID = logs.TransferReference;
            logs.LocationRef = adjustmentHead.WarehouseRef;
            for (int index = 0; index < dgvItems.Rows.Count; index++)
            {
                // Saving details to tblWarehouseAdjustmentLines Table
                adjustmentLine.StockCode    = dgvItems.Rows[index].Cells[0].Value.ToString();
                adjustmentLine.MovementType = dgvItems.Rows[index].Cells[1].Value.ToString();
                adjustmentLine.Qty          = Convert.ToInt32(dgvItems.Rows[index].Cells[2].Value);
                //adjustmentLine.Value = Convert.ToDecimal(dgvItems.Rows[index].Cells[3].Value);
                // Saving details to tblStockMovements Table
                logs.StockCode    = adjustmentLine.StockCode;
                logs.LocationRef  = adjustmentHead.WarehouseRef;
                logs.LocationType = 1;
                logs.SupplierRef  = "N/A";
                if (adjustmentLine.MovementType == "Loss")
                {
                    logs.DeliveredQtyHangers = Convert.ToInt32(dgvItems.Rows[index].Cells[2].Value) * -1;
                }
                else
                {
                    logs.DeliveredQtyHangers = Convert.ToInt32(dgvItems.Rows[index].Cells[2].Value);
                }
                logs.DeliveredQtyGarments = 0;
                logs.DeliveredQtyBoxes    = 0;
                if (adjustmentLine.MovementType == "Loss")
                {
                    logs.MovementType = 7;
                }
                else
                {
                    logs.MovementType = 6;
                }
                logs.MovementDate       = adjustmentHead.MovementDate;
                logs.Reference          = adjustmentHead.Reference;
                logs.StringMovementType = "WarehouseAdjustment-" + adjustmentLine.MovementType;
                logs.RecordType         = "WarehouseAdjustment-Item";
                logs.UserID             = LoggedInUser;
                // Save to the relevent data tables on each itteration of the Datagridview control
                logs.SaveToSysLogTable();
                logs.SaveToStockMovementsTable();
                adjustmentLine.UpdateWarehouseAdjustmentLine();
            }
        }
        private void cmdOK_Click(object sender, EventArgs e)
        {
            clsShopSaleHead saleHead = new clsShopSaleHead();
            clsShopSaleLine saleLine = new clsShopSaleLine();
            clsLogs         logs     = new clsLogs();
            decimal         toConvert;

            saleHead.ShopRef      = txtShopRef.Text.TrimEnd();
            saleHead.ShopName     = lblShopName.Text.TrimEnd();
            saleHead.MovementDate = Convert.ToDateTime(DateTimePicker1.Value);
            decimal.TryParse(txtTotal.Text, System.Globalization.NumberStyles.AllowCurrencySymbol | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands, CultureInfo.CurrentCulture, out toConvert);
            saleHead.Value = toConvert;
            saleHead.Qty   = Convert.ToInt32(txtTotalGarments.Text.TrimEnd());
            decimal.TryParse(txtVAT.Text, System.Globalization.NumberStyles.AllowCurrencySymbol | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands, CultureInfo.CurrentCulture, out toConvert);
            saleHead.VATRate = toConvert;
            saleHead.UserID  = LoggedInUser;
            saleHead.SaveShopSaleHead();
            saleLine.SalesID        = saleHead.GetLastShopSaleHead();
            logs.StockCode          = "ALL";
            logs.SupplierRef        = "ALL";
            logs.LocationRef        = saleHead.ShopRef;
            logs.Qty                = saleHead.Qty;
            logs.RecordType         = "Sales Add-Start";
            logs.Reference          = logs.RecordType;
            logs.MovementDate       = saleHead.MovementDate;
            logs.StringMovementType = "Sales Add";
            logs.UserID             = saleHead.UserID;
            //logs.Reference = "Sales ID: [" + saleHead.SalesID.ToString() + "]";
            logs.SaveToSysLogTable();
            if (FormMode == "New")
            {
                for (int a = 0; a < DgvRecords.Rows.Count; a++)
                {
                    saleLine.StockCode            = DgvRecords.Rows[a].Cells[0].Value.ToString();
                    saleLine.DeliveredQtyGarments = Convert.ToInt32(DgvRecords.Rows[a].Cells[1].Value.ToString());
                    saleLine.CurrentQty           = Convert.ToInt32(DgvRecords.Rows[a].Cells[2].Value.ToString());
                    saleLine.TotalItems           = Convert.ToInt32(DgvRecords.Rows[a].Cells[3].Value.ToString());
                    saleLine.Qty         = Convert.ToInt32(DgvRecords.Rows[a].Cells[4].Value.ToString());
                    saleLine.SalesAmount = Convert.ToDecimal(DgvRecords.Rows[a].Cells[5].Value.ToString());
                    saleLine.SaveShopSaleLine();    // Save to database
                    logs.LocationRef        = saleHead.ShopRef;
                    logs.MovementDate       = saleHead.MovementDate;
                    logs.StockCode          = saleLine.StockCode;
                    logs.MovementValue      = saleLine.SalesAmount;
                    logs.Qty                = saleLine.Qty;
                    logs.StringMovementType = "Shop Sale Add-Item";
                    //    logs.RecordType = "Sale Record [" + logs.StockCode + "]";
                    logs.MovementDate         = saleHead.MovementDate;
                    logs.UserID               = saleHead.UserID;
                    logs.MovementType         = 5;
                    logs.LocationType         = 2;
                    logs.TransferReference    = saleLine.SalesID;
                    logs.DeliveredQtyHangers  = logs.Qty;
                    logs.DeliveredQtyBoxes    = 0;
                    logs.DeliveredQtyGarments = logs.DeliveredQtyBoxes;
                    logs.SupplierRef          = ""; // Add function to clsStock to get the supplier Ref from the table.
                    logs.SaveToSysLogTable();
                    logs.SaveToStockMovementsTable();
                }
                logs.DeleteZeroQtyFromStockMovementsTable();
                logs.StockCode          = "ALL";
                logs.SupplierRef        = "ALL";
                logs.LocationRef        = saleHead.ShopRef;
                logs.Qty                = saleHead.Qty;
                logs.RecordType         = "Sales Add-End";
                logs.MovementDate       = saleHead.MovementDate;
                logs.StringMovementType = "Sales Add";
                logs.UserID             = saleHead.UserID;
                logs.Reference          = "Sales ID: [" + saleHead.SalesID.ToString() + "]";
                logs.SaveToSysLogTable();
            }
            else
            {
                logs.MovementType      = 5;
                logs.TransferReference = Convert.ToInt32(txtSalesID.Text.TrimEnd());
                logs.MovementDate      = OldDate;
                logs.DeleteFromStockMovemmentsTable();
                logs.StockCode          = "ALL";
                logs.SupplierRef        = "ALL";
                logs.LocationRef        = saleHead.ShopRef;
                logs.Qty                = saleHead.Qty;
                logs.RecordType         = "Sales Update-Start";
                logs.MovementDate       = saleHead.MovementDate;
                logs.StringMovementType = "Sales Update";
                logs.UserID             = saleHead.UserID;
                logs.Reference          = "Sales ID: [" + saleHead.SalesID.ToString() + "]";
                logs.SaveToSysLogTable();
                for (int a = 0; a < DgvRecords.Rows.Count - 1; a++)
                {
                    saleLine.StockCode            = DgvRecords.Rows[a].Cells[0].Value.ToString();
                    saleLine.DeliveredQtyGarments = Convert.ToInt32(DgvRecords.Rows[a].Cells[1].Value.ToString());
                    saleLine.CurrentQty           = Convert.ToInt32(DgvRecords.Rows[a].Cells[2].Value.ToString());
                    saleLine.TotalItems           = Convert.ToInt32(DgvRecords.Rows[a].Cells[3].Value.ToString());
                    saleLine.Qty         = Convert.ToInt32(DgvRecords.Rows[a].Cells[4].Value.ToString());
                    saleLine.SalesAmount = Convert.ToDecimal(DgvRecords.Rows[a].Cells[5].Value.ToString());
                    saleLine.UpdateShopSaleLine();    // Save to database
                    logs.LocationRef          = saleHead.ShopRef;
                    logs.MovementDate         = saleHead.MovementDate;
                    logs.StockCode            = saleLine.StockCode;
                    logs.Qty                  = saleLine.Qty;
                    logs.StringMovementType   = "Shop Sale Update";
                    logs.RecordType           = "Sale Record [" + logs.StockCode + "]";
                    logs.MovementDate         = saleHead.MovementDate;
                    logs.UserID               = saleHead.UserID;
                    logs.MovementType         = 5;
                    logs.LocationType         = 2;
                    logs.Reference            = "Sale-Update-Item";
                    logs.TransferReference    = saleLine.SalesID;
                    logs.DeliveredQtyGarments = logs.Qty;
                    logs.DeliveredQtyBoxes    = 0;
                    logs.DeliveredQtyHangers  = logs.DeliveredQtyBoxes;
                    logs.SupplierRef          = ""; // Add function to clsStock to get the supplier Ref from the table.
                    logs.SaveToSysLogTable();
                    logs.SaveToStockMovementsTable();
                }
            }
            Close();
        }
        private void CmdOK_Click(object sender, EventArgs e)
        {
            clsShopAdjustmentHead adjustmentHead = new clsShopAdjustmentHead();
            clsShopAdjustmentLine adjustmentLine = new clsShopAdjustmentLine();
            clsLogs logs = new clsLogs();
            int     Total;

            Total = Convert.ToInt32(txtTotalGain.Text.TrimEnd()) + Convert.ToInt32(txtTotalLoss.Text.TrimEnd());

            int SavedID = 0;

            // Header of both adjustments and log file
            adjustmentHead.ShopRef        = txtWarehouseRef.Text.TrimEnd();
            adjustmentHead.Reference      = txtReference.Text.TrimEnd();
            adjustmentHead.TotalGainItems = Convert.ToInt32(txtTotalGain.Text.TrimEnd());
            adjustmentHead.TotalLossItems = Convert.ToInt32(txtTotalLoss.Text.TrimEnd());
            adjustmentHead.MovementDate   = Convert.ToDateTime(DateTimePicker1.Value);
            adjustmentHead.UserID         = LoggedInUser;
            if (FormMode == "New")
            {
                adjustmentHead.SaveShopAdjustmentHead();
                SavedID = adjustmentHead.GetLastShopAdjustmentHead();
            }
            else
            {
                clsLogs Dlogs = new clsLogs();  // Delete old StockMovements Data from Table
                Dlogs.TransferReference = Convert.ToInt32(TxtSID.Text.TrimEnd());
                Dlogs.MovementDate      = oldDate;
                Dlogs.MovementType      = 6;
                Dlogs.DeleteFromStockMovemmentsTable();
                Dlogs.MovementType = 7;
                Dlogs.DeleteFromStockMovemmentsTable();
                adjustmentHead.ID = Convert.ToInt32(TxtSID.Text.TrimEnd());

                adjustmentHead.UpdateShopAdjustmentHead();
            }
            logs.TransferReference = SavedID;
            adjustmentLine.ID      = SavedID;
            logs.LocationRef       = adjustmentHead.ShopRef;
            for (int index = 0; index < dgvItems.Rows.Count; index++)
            {
                // Saving details to tblWarehouseAdjustmentLines Table
                adjustmentLine.StockCode    = dgvItems.Rows[index].Cells[0].Value.ToString();
                adjustmentLine.MovementType = dgvItems.Rows[index].Cells[1].Value.ToString();
                adjustmentLine.Qty          = Convert.ToInt32(dgvItems.Rows[index].Cells[2].Value);

                // adjustmentLine.Value = Convert.ToDecimal(dgvItems.Rows[index].Cells[3].Value);
                // Saving details to tblStockMovements Table
                logs.StockCode    = adjustmentLine.StockCode;
                logs.LocationRef  = adjustmentHead.ShopRef;
                logs.LocationType = 2;
                logs.SupplierRef  = "N/A";
                if (adjustmentLine.MovementType == "Loss")
                {
                    logs.DeliveredQtyHangers = Convert.ToInt32(dgvItems.Rows[index].Cells[2].Value) * -1;
                }
                else
                {
                    logs.DeliveredQtyHangers = Convert.ToInt32(dgvItems.Rows[index].Cells[2].Value);
                }
                logs.DeliveredQtyGarments = 0;
                logs.DeliveredQtyBoxes    = 0;
                if (adjustmentLine.MovementType == "Loss")
                {
                    logs.MovementType = 7;
                }
                else
                {
                    logs.MovementType = 6;
                }
                logs.MovementDate       = adjustmentHead.MovementDate;
                logs.Reference          = adjustmentHead.Reference;
                logs.StringMovementType = "WarehouseAdjustment-" + adjustmentLine.MovementType;
                logs.RecordType         = "WarehouseAdjustment-Item";
                logs.UserID             = LoggedInUser;
                // Save to the relevent data tables on each itteration of the Datagridview control
                logs.SaveToSysLogTable();
                logs.SaveToStockMovementsTable();
                if (FormMode == "New")
                {
                    adjustmentLine.SaveShopAdjustmentLine();
                }
                else
                {
                    adjustmentLine.UpdateShopAdjustmentLine();
                }
            }
            Close();
        }