private void viewDetails()
 {
     try
     {
         dgvDetailList.DataSource = loSalesOrderDetail.getSalesOrderDetails("ViewAll",dgvList.CurrentRow.Cells[0].Value.ToString());
     }
     catch
     {
         dgvDetailList.DataSource = null;
     }
 }
예제 #2
0
        private void cboSalesOrder_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string _SOId = "";
                try
                {
                    _SOId = cboSalesOrder.SelectedValue.ToString();
                }
                catch { }
                if (_SOId != "")
                {
                    foreach (DataRow _dr in loSalesOrder.getAllData("", _SOId, "").Rows)
                    {
                        txtReference.Text = _dr["Reference"].ToString();
                    }
                    if (lOperation == GlobalVariables.Operation.Add)
                    {
                        dgvDetail.Rows.Clear();
                        foreach (DataRow _drDetails in loSalesOrderDetail.getSalesOrderDetails("", _SOId).Rows)
                        {
                            if (decimal.Parse(_drDetails["Qty Variance"].ToString()) > 0)
                            {
                                int i = dgvDetail.Rows.Add();
                                dgvDetail.Rows[i].Cells["Id"].Value               = "";
                                dgvDetail.Rows[i].Cells["SODetailId"].Value       = _drDetails["Id"].ToString();
                                dgvDetail.Rows[i].Cells["StockId"].Value          = _drDetails["StockId"].ToString();
                                dgvDetail.Rows[i].Cells["StockCode"].Value        = _drDetails["Stock Code"].ToString();
                                dgvDetail.Rows[i].Cells["StockDescription"].Value = _drDetails["Stock Description"].ToString();
                                dgvDetail.Rows[i].Cells["Unit"].Value             = _drDetails["Unit"].ToString();
                                dgvDetail.Rows[i].Cells["LocationId"].Value       = _drDetails["LocationId"].ToString();
                                dgvDetail.Rows[i].Cells["Location"].Value         = _drDetails["Location"].ToString();
                                dgvDetail.Rows[i].Cells["SOQty"].Value            = string.Format("{0:n}", decimal.Parse(_drDetails["Qty Variance"].ToString()));
                                dgvDetail.Rows[i].Cells["QtyOut"].Value           = string.Format("{0:n}", decimal.Parse(_drDetails["Qty Variance"].ToString()));

                                dgvDetail.Rows[i].Cells["Variance"].Value = "0.00";
                                dgvDetail.Rows[i].Cells["Remarks"].Value  = "";
                                dgvDetail.Rows[i].Cells["Status"].Value   = "Add";
                            }
                        }
                    }
                }
            }
            catch
            {
                dgvDetail.Rows.Clear();
            }

            computeTotalQty();
        }
        private void SalesOrderDetailUI_Load(object sender, EventArgs e)
        {
            this.BackColor = Color.FromArgb(int.Parse(GlobalVariables.FormBackColor));

            try
            {
                cboCustomer.DataSource    = loCustomer.getAllData("ViewAll", "", "");
                cboCustomer.DisplayMember = "Name";
                cboCustomer.ValueMember   = "Id";
                cboCustomer.SelectedIndex = -1;
            }
            catch { }

            try
            {
                cboSalesPerson.DataSource    = loSalesPerson.getSalesPersonNames();
                cboSalesPerson.DisplayMember = "Name";
                cboSalesPerson.ValueMember   = "Id";
                cboSalesPerson.SelectedIndex = -1;
            }
            catch { }

            if (lOperation == GlobalVariables.Operation.Edit)
            {
                foreach (DataRow _dr in loSalesOrder.getAllData("", lSalesOrderId, "").Rows)
                {
                    txtId.Text        = _dr["Id"].ToString();
                    dtpDate.Value     = GlobalFunctions.ConvertToDate(_dr["Date"].ToString());
                    txtReference.Text = _dr["Reference"].ToString();
                    cboCustomer.Text  = _dr["Customer"].ToString();

                    cboPriceQuotation.Text = _dr["P.Q. Id"].ToString();
                    txtTerms.Text          = _dr["Terms"].ToString();
                    dtpDueDate.Value       = GlobalFunctions.ConvertToDate(_dr["Due Date"].ToString());
                    txtInstructions.Text   = _dr["Instructions"].ToString();
                    try
                    {
                        cboSalesPerson.SelectedValue = _dr["SalesPerson"].ToString();
                    }
                    catch
                    {
                        cboSalesPerson.Text = "";
                    }
                    lblTotalSOQty.Text       = string.Format("{0:n}", decimal.Parse(_dr["Total S.O. Qty"].ToString()));
                    lblTotalQtyOut.Text      = string.Format("{0:n}", decimal.Parse(_dr["Total Qty Out"].ToString()));
                    lblTotalQtyVariance.Text = string.Format("{0:n}", decimal.Parse(_dr["Total Qty Variance"].ToString()));
                    txtTotalAmount.Text      = string.Format("{0:n}", decimal.Parse(_dr["Total Amount"].ToString()));
                    txtRemarks.Text          = _dr["Remarks"].ToString();

                    foreach (DataRow _drDetails in loSalesOrderDetail.getSalesOrderDetails("", lSalesOrderId).Rows)
                    {
                        int i = dgvDetailStockInventory.Rows.Add();
                        dgvDetailStockInventory.Rows[i].Cells["Id"].Value               = _drDetails["Id"].ToString();
                        dgvDetailStockInventory.Rows[i].Cells["StockId"].Value          = _drDetails["StockId"].ToString();
                        dgvDetailStockInventory.Rows[i].Cells["StockCode"].Value        = _drDetails["Stock Code"].ToString();
                        dgvDetailStockInventory.Rows[i].Cells["StockDescription"].Value = _drDetails["Stock Description"].ToString();
                        dgvDetailStockInventory.Rows[i].Cells["Unit"].Value             = _drDetails["Unit"].ToString();
                        dgvDetailStockInventory.Rows[i].Cells["LocationId"].Value       = _drDetails["LocationId"].ToString();
                        dgvDetailStockInventory.Rows[i].Cells["Location"].Value         = _drDetails["Location"].ToString();
                        dgvDetailStockInventory.Rows[i].Cells["SOQty"].Value            = string.Format("{0:n}", decimal.Parse(_drDetails["S.O. Qty"].ToString()));
                        dgvDetailStockInventory.Rows[i].Cells["QtyOut"].Value           = string.Format("{0:n}", decimal.Parse(_drDetails["Qty Out"].ToString()));
                        dgvDetailStockInventory.Rows[i].Cells["QtyVariance"].Value      = string.Format("{0:n}", decimal.Parse(_drDetails["Qty Variance"].ToString()));
                        dgvDetailStockInventory.Rows[i].Cells["UnitPrice"].Value        = string.Format("{0:n}", decimal.Parse(_drDetails["Unit Price"].ToString()));

                        dgvDetailStockInventory.Rows[i].Cells["DiscountId"].Value     = _drDetails["DiscountId"].ToString();
                        dgvDetailStockInventory.Rows[i].Cells["Discount"].Value       = _drDetails["Discount"].ToString();
                        dgvDetailStockInventory.Rows[i].Cells["DiscountAmount"].Value = string.Format("{0:n}", decimal.Parse(_drDetails["Discount Amount"].ToString()));

                        dgvDetailStockInventory.Rows[i].Cells["TotalPrice"].Value = string.Format("{0:n}", decimal.Parse(_drDetails["Total Price"].ToString()));
                        dgvDetailStockInventory.Rows[i].Cells["Remarks"].Value    = _drDetails["Remarks"].ToString();
                        dgvDetailStockInventory.Rows[i].Cells["Status"].Value     = "Saved";
                    }
                    computeTotalAmount();
                    cboCustomer.Enabled             = false;
                    cboPriceQuotation.Enabled       = false;
                    btnLookUpPriceQuotation.Enabled = false;
                }
            }
            else
            {
                foreach (DataRow _dr in loCommon.getNextTabelSequenceId("SalesOrder").Rows)
                {
                    txtId.Text = _dr[0].ToString();
                }

                cboCustomer.Focus();
            }
        }
예제 #4
0
        private void btnFinalize_Click(object sender, EventArgs e)
        {
            try
            {
                if (!GlobalFunctions.checkRights("tsmStockWithdrawal", "Finalize"))
                {
                    return;
                }

                string _SOId = "";

                foreach (DataRow _drStatus in loInventory.getInventoryStatus(dgvList.CurrentRow.Cells[0].Value.ToString()).Rows)
                {
                    _SOId = _drStatus["SOId"].ToString();

                    if (_drStatus["Final"].ToString() == "Y")
                    {
                        MessageBoxUI _mbStatus = new MessageBoxUI("Stock Inventory is already FINALIZED!", GlobalVariables.Icons.Warning, GlobalVariables.Buttons.OK);
                        _mbStatus.ShowDialog();
                        return;
                    }
                }
                if (dgvList.Rows.Count > 0)
                {
                    DialogResult _dr = new DialogResult();
                    MessageBoxUI _mb = new MessageBoxUI("Are sure you want to continue finalizing this Stock Inventory record?", GlobalVariables.Icons.QuestionMark, GlobalVariables.Buttons.YesNo);
                    _mb.ShowDialog();
                    _dr = _mb.Operation;
                    if (_dr == DialogResult.Yes)
                    {
                        if (loInventory.final(dgvList.CurrentRow.Cells[0].Value.ToString()))
                        {
                            //update SO Detail
                            foreach (DataRow _dr1 in loInventoryDetail.getInventoryDetails("", dgvList.CurrentRow.Cells[0].Value.ToString()).Rows)
                            {
                                //update Qty
                                loSalesOrderDetail.updateQtyOutSalesOrderDetail(_dr1["SODetailId"].ToString(), decimal.Parse(_dr1["Qty Out"].ToString()), decimal.Parse(_dr1["Variance"].ToString()));
                                //updtae TotalPrice
                                decimal _totalPrice = 0;
                                foreach (DataRow _dr2 in loSalesOrderDetail.getSalesOrderDetail(_dr1["SODetailId"].ToString()).Rows)
                                {
                                    _totalPrice = decimal.Parse(_dr2["Qty Out"].ToString()) * decimal.Parse(_dr2["Unit Price"].ToString());
                                    loSalesOrderDetail.updateTotalPriceSalesOrderDetail(_dr1["SODetailId"].ToString(), _totalPrice);
                                }
                            }
                            //update PO Header Qty and Amount
                            decimal _totalQtyOut   = 0;
                            decimal _totalVariance = 0;
                            decimal _totalAmount   = 0;
                            foreach (DataRow _dr3 in loSalesOrderDetail.getSalesOrderDetails("", _SOId).Rows)
                            {
                                _totalQtyOut   += decimal.Parse(_dr3["Qty Out"].ToString());
                                _totalVariance += decimal.Parse(_dr3["Qty Variance"].ToString());
                                _totalAmount   += decimal.Parse(_dr3["Total Price"].ToString());
                            }

                            loSalesOrder.updateSOTotalAmount(_SOId, _totalQtyOut, _totalVariance, _totalAmount);

                            MessageBoxUI _mb1 = new MessageBoxUI("Stock Inventory record has been successfully finalized!", GlobalVariables.Icons.Information, GlobalVariables.Buttons.OK);
                            _mb1.ShowDialog();
                            previewInventoryDetail(dgvList.CurrentRow.Cells[0].Value.ToString());
                            //sendEmailToCreator();
                            refresh("Stock Withdrawal");
                        }
                        else
                        {
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorMessageUI em = new ErrorMessageUI(ex.Message, this.Name, "btnFinalize_Click");
                em.ShowDialog();
                return;
            }
        }