Exemple #1
0
 private void BtnNew_Click(object sender, EventArgs e)
 {
     ClearFld();
     _Tag = "NEW";
     Text = "Purchase Indent [NEW]";
     ControlEnableDisable(false, true);
     TxtVoucherNo.Focus();
     if (ClsGlobal.DateType == "M")
     {
         TxtMiti.Text = _objDate.GetMiti(_objDate.GetServerDate());
         TxtDate.Text = _objDate.GetServerDate().ToShortDateString();
     }
     else
     {
         TxtDate.Text = _objDate.GetServerDate().ToShortDateString();
         TxtMiti.Text = _objDate.GetMiti(Convert.ToDateTime(TxtDate.Text));
     }
     if (TxtDate.Enabled == true)
     {
         Utility.GetVoucherNo1("Purchase Indent", TxtVoucherNo, TxtDate, _Tag, "", _DocId);
     }
     else
     {
         Utility.GetVoucherNo2("Purchase Indent", TxtVoucherNo, txtRequestedBy, _Tag, "", _DocId);
     }
 }
Exemple #2
0
        private void BtnVoucherNoSearch_Click(object sender, EventArgs e)
        {
            if (_SearchKey.Length > 1)
            {
                _SearchKey = "";
            }

            PickList frmPickList = new PickList("PurchaseIndent", _SearchKey);

            if (PickList.dt.Rows.Count > 0)
            {
                frmPickList.ShowDialog();
                if (frmPickList.SelectedList.Count > 0 && _Tag != "NEW")
                {
                    _VoucherNo = frmPickList.SelectedList[0]["VoucherNo"].ToString().Trim();
                    DataSet ds = _objPurchaseIndent.GetDataPurchaseIndentVoucher(_VoucherNo);
                    ClearFld();
                    SetData(ds);
                }
                frmPickList.Dispose();
            }
            else
            {
                MessageBox.Show("No List Available in Purchase Indent !", "Mr. Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtVoucherNo.Focus();
                return;
            }
            TxtVoucherNo.Focus();
        }
Exemple #3
0
 private void BtnDelete_Click(object sender, EventArgs e)
 {
     _Tag = "DELETE";
     ControlEnableDisable(false, false);
     Grid.Enabled               = false;
     Text                       = "Purchase Indent [DELETE]";
     TxtVoucherNo.Enabled       = true;
     BtnVoucherNoSearch.Enabled = true;
     TxtVoucherNo.Focus();
     BtnOk.Enabled     = true;
     BtnCancel.Enabled = true;
 }
Exemple #4
0
        public void ControlEnableDisable(bool btn, bool fld)
        {
            BtnNew.Enabled          = btn;
            BtnEdit.Enabled         = btn;
            BtnDelete.Enabled       = btn;
            BtnNextData.Enabled     = btn;
            BtnPreviousData.Enabled = btn;
            BtnFirstData.Enabled    = btn;
            BtnLastData.Enabled     = btn;
            BtnCopy.Enabled         = btn;
            BtnPrint.Enabled        = btn;
            BtnExit.Enabled         = btn;
            if (BtnNew.Enabled == true)
            {
                BtnNew.Focus();
            }
            TxtVoucherNo.Enabled = fld;
            Utility.EnableDesibleColor(TxtVoucherNo, fld);
            BtnVoucherNoSearch.Enabled = fld;
            TxtMiti.Enabled            = fld;
            Utility.EnableDesibleDateColor(TxtMiti, fld);
            TxtDate.Enabled = fld;
            Utility.EnableDesibleDateColor(TxtDate, fld);

            txtRequestedBy.Enabled = fld;
            Utility.EnableDesibleColor(txtRequestedBy, fld);

            TxtRemarks.Enabled = fld;
            Utility.EnableDesibleColor(TxtRemarks, fld);

            BtnOk.Enabled     = fld;
            BtnCancel.Enabled = fld;

            Grid.Enabled = true;

            if (_Tag.ToString() == "NEW" || _Tag.ToString() == "EDIT")
            {
                if (ClsGlobal.PurchaseVoucherDateControlVal == 'Y')
                {
                    TxtMiti.Enabled = true;
                    Utility.EnableDesibleDateColor(TxtMiti, true);
                    TxtDate.Enabled = true;
                    Utility.EnableDesibleDateColor(TxtDate, true);
                }
                else
                {
                    TxtMiti.Enabled = false;
                    Utility.EnableDesibleDateColor(TxtMiti, false);
                    TxtDate.Enabled = false;
                    Utility.EnableDesibleDateColor(TxtDate, false);
                }

                if (ClsGlobal.PurchaseDepartmentControlVal == 'Y')
                {
                    TxtDepartment.Enabled       = true;
                    TxtDepartment.BackColor     = Color.White;
                    BtnDepartmentSearch.Enabled = true;
                }
                else
                {
                    TxtDepartment.Enabled       = false;
                    TxtDepartment.BackColor     = SystemColors.Control;
                    BtnDepartmentSearch.Enabled = false;
                }

                if (ClsGlobal.PurchaseRemarksControlVal == 'Y')
                {
                    TxtRemarks.Enabled = true;
                    Utility.EnableDesibleColor(TxtRemarks, true);
                }
                else
                {
                    TxtRemarks.Enabled = false;
                    Utility.EnableDesibleColor(TxtRemarks, false);
                }
            }
            else
            {
                TxtMiti.Enabled       = fld;
                TxtDate.Enabled       = fld;
                TxtDepartment.Enabled = fld;
                TxtRemarks.Enabled    = fld;
            }

            if (BtnNew.Enabled == true)
            {
                BtnNew.Focus();
            }
            else if (TxtVoucherNo.Enabled == true)
            {
                TxtVoucherNo.Focus();
            }

            if (TxtGridParticular.Visible == true)
            {
                GridControlMode(false);
                Grid.Focus();
            }
        }
Exemple #5
0
        private void BtnOk_Click(object sender, EventArgs e)
        {
            if (ClsGlobal.CheckDateInsideCompanyPeriod(Convert.ToDateTime(TxtDate.Text)) == 1)
            {
                ClsGlobal.DateMitiRangeMsg();
                return;
            }

            if (string.IsNullOrEmpty(TxtVoucherNo.Text.Trim()))
            {
                MessageBox.Show("Voucher number cannot be left blank.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtVoucherNo.Focus();
                return;
            }
            if (TxtMiti.Text == "  /  /")
            {
                MessageBox.Show("Miti cannot be left blank.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtMiti.Focus();
                return;
            }

            if (TxtDate.Text == "  /  /")
            {
                MessageBox.Show("Date cannot be left blank.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtDate.Focus();
                return;
            }

            if (Grid.Rows.Count <= 0)
            {
                MessageBox.Show("Invoice details not found.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Grid.Focus();
                return;
            }

            if (Grid.Rows.Count == 1 && Grid.Rows[0].Cells["Particular"].Value == null)
            {
                MessageBox.Show("Invoice details not found.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                BtnOk.Enabled = false;
                Grid.Focus();
                return;
            }

            _objPurchaseIndent.Model.EntryFromProject = "Normal";
            _objPurchaseIndent.Model.Gadget           = "Desktop";

            _objPurchaseIndent.Model.VDate       = Convert.ToDateTime(TxtDate.Text);
            _objPurchaseIndent.Model.Tag         = _Tag;
            _objPurchaseIndent.Model.VoucherNo   = TxtVoucherNo.Text.Trim();
            _objPurchaseIndent.Model.VTime       = _objDate.GetServerDateTime();
            _objPurchaseIndent.Model.VMiti       = TxtMiti.Text;
            _objPurchaseIndent.Model.RequestedBy = txtRequestedBy.Text;
            if (!string.IsNullOrEmpty(TxtDepartment.Text))
            {
                string[] dept = TxtDepartment.Tag.ToString().Split('|');
                _objPurchaseIndent.Model.DepartmentId1 = ((dept[0].ToString() == "") ? 0 : Convert.ToInt32(dept[0].ToString()));
                _objPurchaseIndent.Model.DepartmentId2 = ((dept[1].ToString() == "") ? 0 : Convert.ToInt32(dept[1].ToString()));
                _objPurchaseIndent.Model.DepartmentId3 = ((dept[2].ToString() == "") ? 0 : Convert.ToInt32(dept[2].ToString()));
                _objPurchaseIndent.Model.DepartmentId4 = ((dept[3].ToString() == "") ? 0 : Convert.ToInt32(dept[3].ToString()));
            }
            _objPurchaseIndent.Model.Remarks       = TxtRemarks.Text;
            _objPurchaseIndent.Model.BranchId      = ClsGlobal.BranchId;
            _objPurchaseIndent.Model.CompanyUnitId = ClsGlobal.CompanyUnitId;

            PurchaseIndentDetailsViewModel _PurchaseIndentDetails = null;
            int dc = Grid.Rows.Count;

            foreach (DataGridViewRow ro in Grid.Rows)
            {
                if (ro.Cells["Particular"].Value != null)
                {
                    _PurchaseIndentDetails = new PurchaseIndentDetailsViewModel
                    {
                        VoucherNo = _objPurchaseIndent.Model.VoucherNo,
                        Sno       = Grid.Rows.IndexOf(ro) + 1,
                        ProductId = Convert.ToInt32(ro.Cells["ProductId"].Value.ToString())
                    };

                    if (ro.Cells["AltQty"].Value != null)
                    {
                        decimal.TryParse(ro.Cells["AltQty"].Value.ToString().Trim(), out decimal _AltQty);
                        _PurchaseIndentDetails.AltQty = _AltQty;
                    }
                    else
                    {
                        _PurchaseIndentDetails.AltQty = 0;
                    }

                    if (ro.Cells["AltQty"].Value != null)
                    {
                        _PurchaseIndentDetails.ProductAltUnitId = !string.IsNullOrEmpty(ro.Cells["ProductAltUnitId"].Value.ToString()) ? Convert.ToInt32(ro.Cells["ProductAltUnitId"].Value.ToString()) : 0;
                    }

                    _PurchaseIndentDetails.Qty = ro.Cells["Qty"].Value != null?Convert.ToDecimal(ro.Cells["Qty"].Value.ToString().Trim()) : 0;

                    if (ro.Cells["ProductUnitId"].Value != null)
                    {
                        _PurchaseIndentDetails.ProductUnitId = string.IsNullOrEmpty(ro.Cells["ProductUnitId"].Value.ToString()) ? 0 : Convert.ToInt32(ro.Cells["ProductUnitId"].Value.ToString());
                    }
                    else
                    {
                        _PurchaseIndentDetails.ProductUnitId = 0;
                    }

                    _PurchaseIndentDetails.ConversionRatio = ro.Cells["QtyConversion"].Value != null?Convert.ToDecimal(ro.Cells["QtyConversion"].Value.ToString().Trim()) : 0;

                    _PurchaseIndentDetails.Narration = ro.Cells["Narration"].Value.ToString();

                    _objPurchaseIndent.ModelDetails.Add(_PurchaseIndentDetails);
                }
            }

            _objPurchaseIndent.Model.DocId = Convert.ToInt32(TxtVoucherNo.Tag.ToString());
            string output = "";

            if (_Tag == "DELETE")
            {
                DialogResult dialogResult = MessageBox.Show("Are you sure want to Delete Record..??", "Close Form", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dialogResult == DialogResult.No)
                {
                    return;
                }
            }

            if (_Tag == "NEW")
            {
                if (ClsGlobal.ConfirmSave == 1)
                {
                    DialogResult dialogResult = MessageBox.Show("Are you sure want to Save New Record..??", "Close Form", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                    if (dialogResult == DialogResult.Yes)
                    {
                        output = _objPurchaseIndent.SavePurchaseIndent();
                    }
                }
                else
                {
                    output = _objPurchaseIndent.SavePurchaseIndent();
                }
            }
            else
            {
                output = _objPurchaseIndent.SavePurchaseIndent();
            }

            if (string.IsNullOrEmpty(output))
            {
                MessageBox.Show("Error occurred during data submission.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                if (_Tag == "NEW")
                {
                    MessageBox.Show("Voucher number : " + TxtVoucherNo.Text + " has been generated.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (_Tag == "EDIT")
                {
                    MessageBox.Show("Voucher number : " + TxtVoucherNo.Text + " has been updated.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (_Tag == "DELETE")
                {
                    MessageBox.Show("Voucher number : " + TxtVoucherNo.Text + " has been deleted.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                ClearFld();
                if (this._Tag == "NEW")
                {
                    _DocId         = Convert.ToInt32(TxtVoucherNo.Tag.ToString());
                    BtnNew.Enabled = true;
                    BtnNew.PerformClick();
                }
                else if (this._Tag == "EDIT")
                {
                    BtnEdit.Enabled = true;
                    BtnEdit.PerformClick();
                }
                else if (this._Tag == "DELETE")
                {
                    BtnDelete.Enabled = true;
                    BtnDelete.PerformClick();
                }
            }
        }