Beispiel #1
0
        private void CompanySelect()
        {
            if (Grid.Rows.Count > 0)
            {
                ClsGlobal.Initial          = Grid.Rows[Convert.ToInt32(Grid.CurrentRow.Index)].Cells["IniTial"].Value.ToString();
                ClsGlobal.CompanyName      = Grid.Rows[Convert.ToInt32(Grid.CurrentRow.Index)].Cells["Company Name"].Value.ToString();
                ClsGlobal.CompanyStartDate = Convert.ToDateTime(Grid.Rows[Convert.ToInt32(Grid.CurrentRow.Index)].Cells["Start Date"].Value.ToString()).ToShortDateString();
                ClsGlobal.CompanyEndDate   = Convert.ToDateTime(Grid.Rows[Convert.ToInt32(Grid.CurrentRow.Index)].Cells["End Date"].Value.ToString()).ToShortDateString();
                ClsGlobal.DatabaseName     = Grid.Rows[Convert.ToInt32(Grid.CurrentRow.Index)].Cells["Db Name"].Value.ToString();
                DataAccessLayer.Database._CompDatabaseName = Grid.Rows[Convert.ToInt32(Grid.CurrentRow.Index)].Cells["Db Name"].Value.ToString();
                this.Close();

                DataAccessLayer.SystemSetting.ClsCompany _objCompany = new DataAccessLayer.SystemSetting.ClsCompany();
                DataTable     dt     = _objCompany.GetDataCompany(ClsGlobal.Initial);
                StringBuilder strSql = new StringBuilder();
                strSql.Append(dt.Rows[0]["Address"].ToString());
                if (!string.IsNullOrEmpty(dt.Rows[0]["City"].ToString()))
                {
                    strSql.Append(", " + dt.Rows[0]["City"].ToString());
                }
                if (!string.IsNullOrEmpty(dt.Rows[0]["Country"].ToString()))
                {
                    strSql.Append(", " + dt.Rows[0]["Country"].ToString());
                }
                ClsGlobal.CompanyAddress = strSql.ToString();
                strSql.Clear();
                if (!string.IsNullOrEmpty(dt.Rows[0]["PhoneNo"].ToString()))
                {
                    strSql.Append("Phone No : " + dt.Rows[0]["PhoneNo"].ToString());
                }
                if (!string.IsNullOrEmpty(dt.Rows[0]["AltPhoneNo"].ToString()))
                {
                    strSql.Append(", " + dt.Rows[0]["AltPhoneNo"].ToString());
                }
                ClsGlobal.CompanyPhoneNo = strSql.ToString();

                ClsDateMiti _objDate = new ClsDateMiti();
                if (ClsGlobal.DateType == "D")
                {
                    ClsGlobal.CompanyFiscalYear = Convert.ToDateTime(dt.Rows[0]["StartDate"].ToString()).ToShortDateString() + " - " + Convert.ToDateTime(dt.Rows[0]["EndDate"].ToString()).ToShortDateString();
                }
                else
                {
                    ClsGlobal.CompanyStartMiti  = _objDate.GetMiti(Convert.ToDateTime(dt.Rows[0]["StartDate"].ToString()));
                    ClsGlobal.CompanyEndMiti    = _objDate.GetMiti(Convert.ToDateTime(dt.Rows[0]["EndDate"].ToString()));
                    ClsGlobal.CompanyFiscalYear = ClsGlobal.CompanyStartMiti + " - " + ClsGlobal.CompanyEndMiti;
                }

                //---------START UPDATE COMPANY ------------
                Version          versionInfo       = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
                ClsUpdateCompany _objUpdateCompany = new ClsUpdateCompany();
                if (_objUpdateCompany.GetCompanyVersionNo() != versionInfo.ToString())
                {
                    _objUpdateCompany.UpdateCompanyVersionNo(versionInfo.ToString());
                    _objUpdateCompany.CreateView();
                    _objUpdateCompany.InsertDefaultData();
                }
                //---------END UPDATE COMPANY ------------

                ClsGlobal.TodayDateTime = _objDate.GetServerDateTime();
                ClsGlobal.TodayDate     = _objDate.GetServerDate();
                ClsGlobal.EntryControl("");
                ClsGlobal.UserRestriction(ClsGlobal.LoginUserCode, ClsGlobal.Initial);
            }
        }
Beispiel #2
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();
                }
            }
        }