public static string CalTotalForRoundOff(DataTable calculatedTermDT, decimal _basicAmt) { decimal totalAmt = 0; decimal val = 0; totalAmt = _basicAmt; foreach (DataRow ro in calculatedTermDT.Rows) { if (!string.IsNullOrEmpty(ro["Amount"].ToString())) { if (ro["Basis"].ToString().Trim().ToUpper() != "R") { decimal.TryParse(ro["Amount"].ToString().Trim(), out val); if (ro["Sign"].ToString().Trim() == "-") { totalAmt += -val; } else { totalAmt += +val; } } } } return(ClsGlobal.DecimalFormate(totalAmt, 1, ClsGlobal._AmountDecimalFormat).ToString()); }
private string CalTotalForRoundOff() { decimal totalAmt = 0; decimal.TryParse(TxtBasicAmount.Text, out decimal _basicAmt); totalAmt = _basicAmt; foreach (DataGridViewRow ro in Grid.Rows) { if (ro.Cells["Amount"].Value != null) { string sign = ro.Cells["Sign"].Value.ToString().Trim(); if (ro.Cells["Basis"].Value.ToString().Trim().ToUpper() != "R") { decimal.TryParse(ro.Cells["Amount"].Value.ToString().Trim(), out decimal val); if (sign.Trim() == "-") { totalAmt += -val; } else { totalAmt += +val; } } } } return(ClsGlobal.DecimalFormate(totalAmt, 1, ClsGlobal._AmountDecimalFormat).ToString()); }
public static void CurrencyRateValidating(TextBox TxtCurrency, TextBox TxtCurrencyRate, TextBox LblNetAmt, TextBox LblLocalNetAmt, CancelEventArgs e) { if (TxtCurrencyRate.Enabled == false) { return; } if (!string.IsNullOrEmpty(TxtCurrency.Text) && string.IsNullOrEmpty(TxtCurrencyRate.Text)) { MessageBox.Show("Currency Rate Cannot Left Blank.", "Mr solution", MessageBoxButtons.OK, MessageBoxIcon.Information); TxtCurrencyRate.Focus(); return; } decimal.TryParse(TxtCurrencyRate.Text, out decimal CurrencyRate); if (!string.IsNullOrEmpty(TxtCurrency.Text) && CurrencyRate <= 0) { MessageBox.Show("Currency Rate Cannot Zero Value.", "Mr solution", MessageBoxButtons.OK, MessageBoxIcon.Information); TxtCurrencyRate.Focus(); } else if (!string.IsNullOrEmpty(TxtCurrency.Text) && CurrencyRate > 0) { decimal.TryParse(LblNetAmt.Text, out decimal _NetAmt); LblLocalNetAmt.Text = ClsGlobal.DecimalFormate((_NetAmt * CurrencyRate), 1, ClsGlobal._AmountDecimalFormat).ToString(); } }
private void GetOrderData() { DataSet ds = _objSalesOrder.GetDataOrderVoucher(lblOrderNo.Text); DataTable dtdetails = ds.Tables[1]; int j = 1; decimal.TryParse(lblTotalQtyPrimary.Text, out decimal primaryQty); foreach (DataRow drDetails in dtdetails.Rows) { for (int i = 0; i < Convert.ToDecimal(drDetails["Qty"].ToString()); i++) { Grid.Rows.Add(); Grid.Rows[Grid.Rows.Count - 1].Cells["SNo"].Value = j; Grid.Rows[Grid.Rows.Count - 1].Cells["ProductDesc"].Value = drDetails["ProductDesc"].ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["ProductId"].Value = drDetails["ProductId"].ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["Qty"].Value = "1"; Grid.Rows[Grid.Rows.Count - 1].Cells["Rate"].Value = drDetails["SalesRate"].ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["Note"].Value = drDetails["ResOrderNotes"].ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["TermDetails"].Value = drDetails["TermDetails"].ToString(); j++; } primaryQty += Convert.ToDecimal(drDetails["Qty"].ToString()); } lblTotalQtyPrimary.Text = ClsGlobal.DecimalFormate(primaryQty, 1, ClsGlobal._CurrencyDecimalFormat).ToString(); }
private void SetData(DataTable dt) { TxtDescription.Tag = dt.Rows[0]["MemberTypeId"].ToString(); TxtDescription.Text = dt.Rows[0]["MemberTypeDesc"].ToString(); TxtDiscountPercent.Text = ClsGlobal.DecimalFormate(Convert.ToDecimal(dt.Rows[0]["DiscountPercent"].ToString()), 1, ClsGlobal._QtyDecimalFormat).ToString(); CbActive.Checked = Convert.ToBoolean(dt.Rows[0]["Status"].ToString()); TxtDescription.SelectAll(); }
private void SetData(DataTable dt) { TxtDescription.Tag = dt.Rows[0]["CurrencyId"].ToString(); TxtDescription.Text = dt.Rows[0]["CurrencyDesc"].ToString(); TxtShortName.Text = dt.Rows[0]["CurrencyShortName"].ToString(); TxtCurrUnit.Text = dt.Rows[0]["CurrencyUnit"].ToString(); TxtCurrRate.Text = ClsGlobal.DecimalFormate(Convert.ToDecimal(dt.Rows[0]["CurrencyRate"].ToString()), 1, ClsGlobal._CurrencyDecimalFormat).ToString(); CbActive.Checked = Convert.ToBoolean(dt.Rows[0]["Status"].ToString()); TxtDescription.SelectAll(); }
private void SetData(DataTable dt) { TxtDescription.Tag = dt.Rows[0]["MainSalesmanId"].ToString(); TxtDescription.Text = dt.Rows[0]["MainSalesmanDesc"].ToString(); TxtShortName.Text = dt.Rows[0]["MainSalesmanShortName"].ToString(); CbActive.Checked = Convert.ToBoolean(dt.Rows[0]["Status"].ToString()); TxtLedger.Text = dt.Rows[0]["GlDesc"].ToString(); TxtLedger.Tag = dt.Rows[0]["LedgerId"].ToString(); TxtAddress.Text = dt.Rows[0]["Address"].ToString(); TxtPhoneNo.Text = dt.Rows[0]["PhoneNo"].ToString(); TxtMobileNo.Text = dt.Rows[0]["MobileNo"].ToString(); TxtCommissionRate.Text = ClsGlobal.DecimalFormate(Convert.ToDecimal(dt.Rows[0]["CommissionRate"].ToString()), 1, ClsGlobal._AmountDecimalFormat).ToString(); TxtDescription.SelectAll(); }
private void TxtGridQty_Validating(object sender, System.ComponentModel.CancelEventArgs e) { decimal.TryParse(TxtGridQty.Text, out decimal _Qty); if (_Qty <= 0) { TxtGridQty.Focus(); return; } decimal _convRatio = TxtGridParticular.AltConversion; if (ClsGlobal.InventoryAltQtyConversion == "Y" && TxtGridAltQty.Enabled == true && Convert.ToDecimal(TxtGridParticular.ProductQtyConversion.ToString()) > 0 && _convRatio > 0) { TxtGridAltQty.Text = ClsGlobal.DecimalFormate((Convert.ToDecimal(string.IsNullOrEmpty(TxtGridQty.Text) ? "0" : TxtGridQty.Text) / Convert.ToDecimal(TxtGridParticular.ProductQtyConversion.ToString()) * _convRatio), 1, ClsGlobal._QtyDecimalFormat).ToString(); } }
private bool SetTextBoxValueToGrid() { DataGridViewRow ro = new DataGridViewRow(); ro = Grid.Rows[Grid.CurrentRow.Index]; ro.Cells["SNo"].Value = Grid.CurrentRow.Index + 1; if (!string.IsNullOrEmpty(TxtGridPercent.Text)) { ro.Cells["DisPercent"].Value = ClsGlobal.DecimalFormate(Convert.ToDecimal(TxtGridPercent.Text), 1, ClsGlobal._AmountDecimalFormat); TxtGridPercent.Text = ""; } if (!string.IsNullOrEmpty(TxtGridRate.Text)) { ro.Cells["ProductRate"].Value = ClsGlobal.DecimalFormate(Convert.ToDecimal(TxtGridRate.Text), 1, ClsGlobal._AmountDecimalFormat); TxtGridRate.Text = ""; } return(true); }
private void SetData(DataTable dt) { TxtDescription.Tag = dt.Rows[0]["TermId"].ToString(); TxtDescription.Text = dt.Rows[0]["TermDesc"].ToString(); TxtTermPosition.Text = dt.Rows[0]["TermPosition"].ToString(); ChkActive.Checked = Convert.ToBoolean(dt.Rows[0]["Status"].ToString()); ChkProfitability.Checked = Convert.ToBoolean(dt.Rows[0]["Profitability"].ToString()); ChkSupressZero.Checked = Convert.ToBoolean(dt.Rows[0]["SupressZero"].ToString()); TxtLedger.Text = dt.Rows[0]["ledgerdesc"].ToString(); TxtLedger.Tag = dt.Rows[0]["ledgerId"].ToString(); CmbBasis.Text = dt.Rows[0]["Basis"].ToString(); CmbBillwise.Text = dt.Rows[0]["Billwise"].ToString(); CmbCategory.Text = dt.Rows[0]["Category"].ToString(); CmbSTSign.Text = dt.Rows[0]["STSign"].ToString(); CmbTermType.Text = dt.Rows[0]["TermType"].ToString(); TxtTermRate.Text = ClsGlobal.DecimalFormate(Convert.ToDecimal(dt.Rows[0]["TermRate"].ToString()), 1, ClsGlobal._AmountDecimalFormat); TxtFormula.Text = dt.Rows[0]["Formula"].ToString(); TxtDescription.SelectAll(); }
private void SetData(DataTable dt) { TxtDescription.Tag = dt.Rows[0]["SubLedgerId"].ToString(); TxtDescription.Text = dt.Rows[0]["SubledgerDesc"].ToString(); TxtShortName.Text = dt.Rows[0]["SubledgerShortName"].ToString(); CbActive.Checked = Convert.ToBoolean(dt.Rows[0]["Status"].ToString()); TxtLedger.Text = dt.Rows[0]["Gldesc"].ToString(); TxtCountry.Text = dt.Rows[0]["Country"].ToString(); TxtAddress.Text = dt.Rows[0]["Address"].ToString(); TxtPhoneNo.Text = dt.Rows[0]["PhoneNo"].ToString(); TxtMobileNo.Text = dt.Rows[0]["MobileNo"].ToString(); TxtFax.Text = dt.Rows[0]["Fax"].ToString(); TxtEmailId.Text = dt.Rows[0]["EmailId"].ToString(); TxtBankAccountNo.Text = dt.Rows[0]["BankAccountNo"].ToString(); TxtInterestRate.Text = ClsGlobal.DecimalFormate(Convert.ToDecimal(dt.Rows[0]["InterestRate"].ToString()), 1, ClsGlobal._AmountDecimalFormat).ToString(); TxtNationalId.Text = dt.Rows[0]["NationalId"].ToString(); TxtPanNo.Text = dt.Rows[0]["PanNo"].ToString(); TxtDescription.SelectAll(); }
public static void CurrencyValidating(TextBox TxtCurrency, TextBox TxtCurrencyRate, TextBox LblNetAmt, TextBox LblLocalNetAmt, string ModuleName, CancelEventArgs e) { if (TxtCurrency.Enabled == false) { return; } if ((ModuleName == "SALES" ? ClsGlobal.SalesMCurrencyControlVal == 'Y': ClsGlobal.PurchaseMCurrencyControlVal == 'Y') && string.IsNullOrEmpty(TxtCurrency.Text)) { MessageBox.Show("Currency Cannot Left Blank.", "Mr solution", MessageBoxButtons.OK, MessageBoxIcon.Information); TxtCurrency.Focus(); } if (string.IsNullOrEmpty(TxtCurrency.Text)) { TxtCurrencyRate.Text = ""; decimal.TryParse(LblNetAmt.Text, out decimal _NetAmt); LblLocalNetAmt.Text = ClsGlobal.DecimalFormate((_NetAmt * 1), 1, ClsGlobal._AmountDecimalFormat).ToString(); } }
private void TxtGridAltQty_Validating(object sender, System.ComponentModel.CancelEventArgs e) { decimal _convRatio = TxtGridParticular.AltConversion; if (ClsGlobal.InventoryAltQtyConversionRatioChange == "Y" && !string.IsNullOrEmpty(TxtGridAltQty.Text)) { ConversionQty frm = new ConversionQty(ClsGlobal.DecimalFormate(Convert.ToDecimal(TxtGridParticular.ProductQtyConversion), 1, ClsGlobal._QtyDecimalFormat)); frm.ShowDialog(); TxtGridParticular.ProductQtyConversion = frm._ConversionQty; } if (ClsGlobal.InventoryAltQtyConversion == "Y" && Convert.ToDecimal(TxtGridParticular.ProductQtyConversion.ToString()) > 0 && _convRatio > 0) { TxtGridQty.Text = ClsGlobal.DecimalFormate((Convert.ToDecimal(string.IsNullOrEmpty(TxtGridAltQty.Text) ? "0" : TxtGridAltQty.Text) * Convert.ToDecimal(TxtGridParticular.ProductQtyConversion.ToString()) / _convRatio), 1, ClsGlobal._QtyDecimalFormat).ToString(); } else if (ClsGlobal.InventoryAltQtyConversion == "N" && _StartTermCalculation == true && Convert.ToDecimal(TxtGridParticular.ProductQtyConversion.ToString()) > 0 && _convRatio > 0) { TxtGridQty.Text = ClsGlobal.DecimalFormate((Convert.ToDecimal(string.IsNullOrEmpty(TxtGridAltQty.Text) ? "0" : TxtGridAltQty.Text) * Convert.ToDecimal(TxtGridParticular.ProductQtyConversion.ToString()) / _convRatio), 1, ClsGlobal._QtyDecimalFormat).ToString(); } }
private void CalTotal() { decimal totalRecAmt = 0; foreach (DataGridViewRow ro in Grid.Rows) { if (ro.Cells["Amount"].Value != null) { string sign = ro.Cells["Sign"].Value.ToString(); decimal.TryParse(ro.Cells["Amount"].Value.ToString(), out decimal val); if (sign.Trim() == "-") { totalRecAmt += -val; } else { totalRecAmt += +val; } } } TxtTotalTermAmount.Text = ClsGlobal.DecimalFormate(totalRecAmt, 1, ClsGlobal._AmountDecimalFormat).ToString(); }
private bool SetTextBoxValueToGrid() { if (string.IsNullOrEmpty(TxtGridParticular.Text)) { TxtGridParticular.Focus(); return(false); // return false for not add grid new 1 row } else { Utility.EnableDesibleColor(TxtGridAltUOM, true); Utility.EnableDesibleColor(TxtGridAltQty, true); DataGridViewRow ro = new DataGridViewRow(); ro = Grid.Rows[Grid.CurrentRow.Index]; ro.Cells["SNo"].Value = Grid.CurrentRow.Index + 1; ro.Cells["Particular"].Value = TxtGridParticular.Text; ro.Cells["ProductId"].Value = TxtGridParticular.Tag.ToString(); ro.Cells["AltConversion"].Value = TxtGridParticular.AltConversion.ToString(); ro.Cells["ProductShortName"].Value = TxtGridParticular.ProductShortName.ToString(); ro.Cells["QtyConversion"].Value = TxtGridParticular.ProductQtyConversion.ToString(); if (!string.IsNullOrEmpty(TxtGridAltQty.Text)) { ro.Cells["AltQty"].Value = ClsGlobal.DecimalFormate(Convert.ToDecimal(TxtGridAltQty.Text), 1, ClsGlobal._AltQtyDecimalFormat); } ro.Cells["AltUOM"].Value = TxtGridAltUOM.Text; ro.Cells["ProductAltUnitId"].Value = !string.IsNullOrEmpty(TxtGridAltUOM.Tag.ToString()) ? TxtGridAltUOM.Tag.ToString() : "0"; if (!string.IsNullOrEmpty(TxtGridQty.Text)) { ro.Cells["Qty"].Value = ClsGlobal.DecimalFormate(Convert.ToDecimal(TxtGridQty.Text), 1, ClsGlobal._QtyDecimalFormat); } ro.Cells["QtyUOM"].Value = TxtGridQtyUOM.Text; ro.Cells["ProductUnitId"].Value = !string.IsNullOrEmpty(TxtGridQtyUOM.Tag.ToString()) ? TxtGridQtyUOM.Tag.ToString() : "0"; ro.Cells["Narration"].Value = TxtGridNarration.Text.ToString(); } return(true); // return true for add grid new row }
private void SetData(DataSet ds) { DataTable dtMaster = ds.Tables[0]; DataTable dtDetails = ds.Tables[1]; TxtVoucherNo.Text = dtMaster.Rows[0]["VoucherNo"].ToString(); _VoucherNo = dtMaster.Rows[0]["VoucherNo"].ToString(); TxtDate.Text = dtMaster.Rows[0]["VDate"].ToString(); TxtMiti.Text = dtMaster.Rows[0]["VMiti"].ToString(); if (string.IsNullOrEmpty(dtMaster.Rows[0]["DepartmentDesc1"].ToString()) || string.IsNullOrEmpty(dtMaster.Rows[0]["DepartmentDesc2"].ToString()) || string.IsNullOrEmpty(dtMaster.Rows[0]["DepartmentDesc3"].ToString()) || string.IsNullOrEmpty(dtMaster.Rows[0]["DepartmentDesc4"].ToString())) { string[] Dept = new string[] { dtMaster.Rows[0]["DepartmentDesc1"].ToString(), "|", dtMaster.Rows[0]["DepartmentDesc2"].ToString(), "|", dtMaster.Rows[0]["DepartmentDesc3"].ToString(), "|", dtMaster.Rows[0]["DepartmentDesc3"].ToString() }; TxtDepartment.Text = string.Concat(Dept); string[] Depttag = new string[] { dtMaster.Rows[0]["DepartmentId1"].ToString(), "|", dtMaster.Rows[0]["DepartmentId2"].ToString(), "|", dtMaster.Rows[0]["DepartmentId3"].ToString(), "|", dtMaster.Rows[0]["DepartmentId4"].ToString() }; TxtDepartment.Tag = string.Concat(Depttag); } txtRequestedBy.Text = dtMaster.Rows[0]["RequestedBy"].ToString(); TxtRemarks.Text = dtMaster.Rows[0]["Remarks"].ToString(); foreach (DataRow drDetails in dtDetails.Rows) { Grid.Rows[Grid.Rows.Count - 1].Cells["SNo"].Value = Grid.Rows.Count.ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["ProductShortName"].Value = drDetails["ProductShortName"].ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["Particular"].Value = drDetails["ProductDesc"].ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["ProductId"].Value = drDetails["ProductId"].ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["AltConversion"].Value = drDetails["AltConv"].ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["AltQty"].Value = ClsGlobal.DecimalFormate(Convert.ToDecimal(drDetails["AltQty"].ToString()), 1, ClsGlobal._AltQtyDecimalFormat).ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["AltUOM"].Value = drDetails["ProductAltUnitDesc"].ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["ProductAltUnitId"].Value = drDetails["ProductAltUnit"].ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["Qty"].Value = ClsGlobal.DecimalFormate(Convert.ToDecimal(drDetails["Qty"].ToString()), 1, ClsGlobal._QtyDecimalFormat).ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["QtyUOM"].Value = drDetails["ProductUnitDesc"].ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["ProductUnitId"].Value = drDetails["ProductUnit"].ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["QtyConversion"].Value = ClsGlobal.DecimalFormate(Convert.ToDecimal(drDetails["ConversionRatio"].ToString()), 1, ClsGlobal._AmountDecimalFormat).ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["Narration"].Value = drDetails["Narration"].ToString(); Grid.Rows.Add(); } }
private void SetData(DataSet ds) { DataTable dtMaster = ds.Tables[0]; DataTable dtDetails = ds.Tables[1]; _SchemeId = Convert.ToInt32(dtMaster.Rows[0]["SchemeId"].ToString()); TxtDescription.Text = dtMaster.Rows[0]["SchemeName"].ToString(); if (dtMaster.Rows[0]["SchemeWise"].ToString() == "Product") { RdoProduct.Enabled = true; RdoProduct.Checked = true; RdoProductGroup.Enabled = false; RdoProductSubGroup.Enabled = false; RdoGroupWiseGroup.Enabled = false; RdoSubGroupWiseGroup.Enabled = false; RdoSubGroupWiseSubGroup.Enabled = false; } else if (dtMaster.Rows[0]["SchemeWise"].ToString() == "ProductGroup") { RdoProductGroup.Enabled = true; RdoProductGroup.Checked = true; RdoProduct.Enabled = false; RdoProductSubGroup.Enabled = false; RdoGroupWiseGroup.Enabled = false; RdoSubGroupWiseGroup.Enabled = false; RdoSubGroupWiseSubGroup.Enabled = false; } else if (dtMaster.Rows[0]["SchemeWise"].ToString() == "ProductSubGroup") { RdoProductSubGroup.Enabled = true; RdoProductSubGroup.Checked = true; RdoProduct.Enabled = false; RdoProductGroup.Enabled = false; RdoGroupWiseGroup.Enabled = false; RdoSubGroupWiseGroup.Enabled = false; RdoSubGroupWiseSubGroup.Enabled = false; } else if (dtMaster.Rows[0]["SchemeWise"].ToString() == "Group") { RdoGroupWiseGroup.Enabled = true; RdoGroupWiseGroup.Checked = true; RdoProduct.Enabled = false; RdoProductGroup.Enabled = false; RdoProductSubGroup.Enabled = false; RdoSubGroupWiseGroup.Enabled = false; RdoSubGroupWiseSubGroup.Enabled = false; } else if (dtMaster.Rows[0]["SchemeWise"].ToString() == "SubGroupGroup") { RdoSubGroupWiseGroup.Enabled = true; RdoSubGroupWiseGroup.Checked = true; RdoProduct.Enabled = false; RdoProductGroup.Enabled = false; RdoProductSubGroup.Enabled = false; RdoGroupWiseGroup.Enabled = false; RdoSubGroupWiseSubGroup.Enabled = false; } else if (dtMaster.Rows[0]["SchemeWise"].ToString() == "SubGroupSubGroup") { RdoSubGroupWiseSubGroup.Enabled = true; RdoSubGroupWiseSubGroup.Checked = true; RdoProduct.Enabled = false; RdoProductGroup.Enabled = false; RdoProductSubGroup.Enabled = false; RdoGroupWiseGroup.Enabled = false; RdoSubGroupWiseGroup.Enabled = false; } if (dtDetails.Rows.Count > 0) { TxtPercentRate.Text = ClsGlobal.DecimalFormate(Convert.ToDecimal(dtDetails.Rows[0]["DiscountPercent"].ToString()), 1, ClsGlobal._RateDecimalFormat).ToString(); if (ClsGlobal.DateType == "M") { TxtDateFrom.Text = _objDate.GetMiti(Convert.ToDateTime(dtDetails.Rows[0]["StartDate"].ToString())); TxtDateTo.Text = _objDate.GetMiti(Convert.ToDateTime(dtDetails.Rows[0]["EndDate"].ToString())); } else { TxtDateFrom.Text = Convert.ToDateTime(dtDetails.Rows[0]["StartDate"].ToString()).ToShortDateString(); TxtDateTo.Text = Convert.ToDateTime(dtDetails.Rows[0]["EndDate"].ToString()).ToShortDateString(); } foreach (DataRow dr in dtDetails.Rows) { Grid.Rows[Grid.Rows.Count - 1].Cells["SNo"].Value = Grid.Rows.Count.ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["Product"].Value = dr["ProductDesc"].ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["ProductId"].Value = dr["ProductId"].ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["PGroup"].Value = dr["ProductGrpDesc"].ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["ProductGrpId"].Value = dr["ProductGrpId"].ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["PSubGroup"].Value = dr["ProductSubGrpDesc"].ToString(); Grid.Rows[Grid.Rows.Count - 1].Cells["ProductSubGrpId"].Value = dr["ProductSubGrpId"].ToString(); if (Convert.ToDecimal(dr["DiscountPercent"].ToString()) > 0) { Grid.Rows[Grid.Rows.Count - 1].Cells["DisPercent"].Value = ClsGlobal.DecimalFormate(Convert.ToDecimal(dr["DiscountPercent"].ToString()), 1, ClsGlobal._AmountDecimalFormat); } else { Grid.Rows[Grid.Rows.Count - 1].Cells["DisPercent"].Value = ""; } if (Convert.ToDecimal(dr["SchemeRate"].ToString()) > 0) { Grid.Rows[Grid.Rows.Count - 1].Cells["ProductRate"].Value = ClsGlobal.DecimalFormate(Convert.ToDecimal(dr["SchemeRate"].ToString()), 1, ClsGlobal._AmountDecimalFormat); } else { Grid.Rows[Grid.Rows.Count - 1].Cells["ProductRate"].Value = ""; } Grid.Rows[Grid.Rows.Count - 1].Cells["Action"].Value = Properties.Resources.Delete_16; Grid.Rows.Add(); } } }
private void LoadProduct(string GroupId = "", string SubGroupId = "") { Grid.Rows.Clear(); DataTable dt1 = _objProductScheme.GetProduct(GroupId, SubGroupId); int i = 1; foreach (DataRow dr in dt1.Rows) { Grid.Rows.Add(i, dr["ProductId"].ToString(), dr["ProductDesc"].ToString(), dr["ProductGrpId"].ToString(), dr["ProductGrpDesc"].ToString(), dr["ProductSubGrpId"].ToString(), dr["ProductSubGrpDesc"].ToString(), dr["Percent"].ToString(), ClsGlobal.DecimalFormate(Convert.ToDecimal(dr["Rate"].ToString()), 1, ClsGlobal._AmountDecimalFormat).ToString(), Properties.Resources.Delete_16); i++; } }
private void TxtGridRatePercent_Validating(object sender, System.ComponentModel.CancelEventArgs e) { int indx = Grid.CurrentRow.Index; decimal totalRecAmt = 0; int i = 0; decimal.TryParse(TxtGridRatePercent.Text, out decimal output); TxtGridRatePercent.Text = ClsGlobal.DecimalFormate(output, 1, ClsGlobal._AmountDecimalFormat).ToString(); decimal percent = Convert.ToDecimal(Grid[7, indx].Value.ToString()); if (output <= 0 && Convert.ToDecimal(TxtGridAmount.Text) <= 0) { TxtGridAmount.Text = ClsGlobal.DecimalFormate(0, 1, ClsGlobal._AmountDecimalFormat).ToString(); } else if (output <= 0 && percent > 0) { TxtGridAmount.Text = ClsGlobal.DecimalFormate(0, 1, ClsGlobal._AmountDecimalFormat).ToString(); } totalRecAmt = Convert.ToDecimal(TxtBasicAmount.Text); if (!string.IsNullOrEmpty(_ExistTermData)) { string[] val1 = _ExistTermData.Split('|'); string ratepercent1 = val1[2]; arrRatepercent1 = ratepercent1.Split(','); } foreach (DataGridViewRow ro in Grid.Rows) { if (indx == i) { if (ro.Cells["Basis"].Value.ToString().Trim().ToUpper() == "V") { string formula = ro.Cells["Formula"].Value.ToString(); if (output > 0) { if (string.IsNullOrEmpty(formula)) { TxtGridAmount.Text = ClsGlobal.DecimalFormate(((totalRecAmt / 100) * output), 1, ClsGlobal._AmountDecimalFormat).ToString(); } else { DataTable GridTable = ClsGlobal.GridToDataTable(Grid); DataTable myTable = new DataTable(); myTable = GridTable.Clone(); totalRecAmt = CalBasicAmt4Formula(formula, GridTable, myTable); TxtGridAmount.Text = ClsGlobal.DecimalFormate((totalRecAmt / 100 * output), 1, ClsGlobal._AmountDecimalFormat).ToString(); } } myGridTxtAmt = TxtGridAmount.Text; SetTextBoxValueToGrid(); } else if (ro.Cells["Basis"].Value.ToString().Trim().ToUpper() == "Q") { if (output > 0) { TxtGridAmount.Text = ClsGlobal.DecimalFormate((_Qty * output), 1, ClsGlobal._AmountDecimalFormat).ToString(); } myGridTxtAmt = TxtGridAmount.Text; SetTextBoxValueToGrid(); } TxtGridAmount.Focus(); decimal.TryParse(TxtGridAmount.Text, out decimal txtBoxGridAmount); if (ro.Cells["Basis"].Value.ToString().Trim().ToUpper() != "R") { CalTermAmount(indx, txtBoxGridAmount, "P"); } return; } else { if (ro.Cells["Amount"].Value != null) { string sign = ro.Cells["Sign"].Value.ToString(); decimal.TryParse(ro.Cells["Amount"].Value.ToString(), out decimal val); if (sign.Trim() == "-") { totalRecAmt += -val; } else { totalRecAmt += +val; } } } i++; } }
private void TxtGridAmount_Validating(object sender, System.ComponentModel.CancelEventArgs e) { int indx = Grid.CurrentRow.Index; if (myGridTxtAmt != TxtGridAmount.Text) { Grid[7, indx].Value = ClsGlobal.DecimalFormate(0, 1, ClsGlobal._AmountDecimalFormat).ToString(); TxtGridRatePercent.Text = ClsGlobal.DecimalFormate(0, 1, ClsGlobal._AmountDecimalFormat).ToString(); } if (SetTextBoxValueToGrid() == true) { GridControlMode(false); if (Grid.Rows.Count - 1 == indx) { Grid.CurrentCell = Grid.Rows[Grid.CurrentRow.Index].Cells["TermRate"]; GridControlMode(false); Grid.ClearSelection(); } else { Grid.CurrentCell = Grid.Rows[Grid.CurrentRow.Index + 1].Cells["TermRate"]; if (Grid[2, indx + 1].Value.ToString().Trim().ToUpper() == "R") { GridControlMode(false); Grid.ClearSelection(); } else { GridControlMode(true); } } } decimal totalRecAmt = 0; int i = 0; totalRecAmt = Convert.ToDecimal(TxtBasicAmount.Text); foreach (DataGridViewRow ro in Grid.Rows) { if (indx == i) { decimal.TryParse(Grid[8, indx].Value.ToString(), out decimal val); if (ro.Cells["Basis"].Value.ToString().Trim().ToUpper() != "R") { CalTermAmount(indx, val, "A"); } return; } else { if (ro.Cells["Amount"].Value != null) { string sign = ro.Cells["Sign"].Value.ToString(); decimal.TryParse(ro.Cells["Amount"].Value.ToString(), out decimal val); if (sign.Trim() == "-") { totalRecAmt += -val; } else { totalRecAmt += +val; } } } i++; } CalTotal(); }
private void FrmTerm_Load(object sender, EventArgs e) { Grid.AutoGenerateColumns = false; TxtBasicAmount.BackColor = SystemColors.Control; TxtTotalTermAmount.BackColor = SystemColors.Control; DataTable dt = _objSalesBillingTerm.GetTermListForTermCalculation(_Module, ClsGlobal.BranchId, _ProductId); dt.Columns.Add("Amount"); decimal _totalBasicAmt = 0;; decimal.TryParse(TxtBasicAmount.Text, out decimal _basicAmt); _totalBasicAmt = _basicAmt; dt.DefaultView.Sort = "TermPosition ASC"; dt = dt.DefaultView.ToTable(); #region ----------- if exist data update rate percent and manual value in datatable------- if (!string.IsNullOrEmpty(_ExistTermData)) { string[] val = _ExistTermData.Split('|'); string sign = val[0]; string sn = val[1]; string ratepercent = val[2]; string amount = val[3]; string[] arrsign = sign.Split(','); string[] arrsn = sn.Split(','); string[] arrRatepercent = ratepercent.Split(','); string[] arrAmount = amount.Split(','); for (int j = 0; j < arrsn.Length; j++) { DataRow[] dr1 = dt.Select("TermId='" + arrsn[j] + "'"); dr1[0]["TermRate"] = arrRatepercent[j]; if (Convert.ToDecimal(arrRatepercent[j]) == 0) { dr1[0]["Amount"] = ClsGlobal.DecimalFormate(Convert.ToDecimal(arrAmount[j]), 1, ClsGlobal._AmountDecimalFormat).ToString(); } else { dr1[0]["Amount"] = ClsGlobal.DecimalFormate(0, 1, ClsGlobal._AmountDecimalFormat).ToString(); } _ExistTermData = ""; dt.AcceptChanges(); } } #endregion int i = 1; #region ----------- calculate term value from datatable DT and update in Grid ------- foreach (DataRow r in dt.Rows) { if (dt.Rows.Count > 0) { string formula = ""; var index = Grid.Rows.Add(); Grid.Rows[index].Cells["SNo"].Value = i; Grid.Rows[index].Cells["TermId"].Value = r["TermId"].ToString(); Grid.Rows[index].Cells["TermDesc"].Value = r["TermDesc"].ToString(); Grid.Rows[index].Cells["Basis"].Value = r["Basis"].ToString(); Grid.Rows[index].Cells["Sign"].Value = r["Sign"].ToString(); Grid.Rows[index].Cells["TermRate"].Value = ClsGlobal.DecimalFormate(Convert.ToDecimal(r["TermRate"].ToString()), 1, ClsGlobal._AmountDecimalFormat).ToString(); decimal.TryParse(r["TermRate"].ToString(), out decimal output); decimal.TryParse(r["Amount"].ToString(), out decimal amt); Grid.Rows[index].Cells["Formula"].Value = r["Formula"].ToString(); Grid.Rows[index].Cells["TermPosition"].Value = r["TermPosition"].ToString(); formula = r["Formula"].ToString(); if (r["Basis"].ToString().Trim().ToUpper() == "V") { if (amt > 0) { Grid.Rows[index].Cells["Amount"].Value = ClsGlobal.DecimalFormate(amt, 1, ClsGlobal._AmountDecimalFormat).ToString(); } else { if (output > 0) { if (i == 1) { Grid.Rows[index].Cells["Amount"].Value = ClsGlobal.DecimalFormate(((_basicAmt / 100) * output), 1, ClsGlobal._AmountDecimalFormat).ToString(); } else { if (string.IsNullOrEmpty(formula)) { decimal _CalCurrentBasicAmt = CalCurrentBasicAmt(i - 1); Grid.Rows[index].Cells["Amount"].Value = ClsGlobal.DecimalFormate(((_CalCurrentBasicAmt / 100) * output), 1, ClsGlobal._AmountDecimalFormat).ToString(); } else { DataTable GridTable = ClsGlobal.GridToDataTable(Grid); DataTable myTable = new DataTable(); myTable = GridTable.Clone(); decimal _CalCurrentBasicAmt = 0; _CalCurrentBasicAmt = CalBasicAmt4Formula(formula, GridTable, myTable); Grid.Rows[index].Cells["Amount"].Value = ClsGlobal.DecimalFormate(((_CalCurrentBasicAmt / 100) * output), 1, ClsGlobal._AmountDecimalFormat).ToString(); } } } else { Grid.Rows[index].Cells["Amount"].Value = ClsGlobal.DecimalFormate(0, 1, ClsGlobal._AmountDecimalFormat).ToString(); } } } else if (r["Basis"].ToString().Trim().ToUpper() == "Q") { if (amt > 0) { Grid.Rows[index].Cells["Amount"].Value = ClsGlobal.DecimalFormate(Convert.ToDecimal(r["Amount"].ToString()), 1, ClsGlobal._AmountDecimalFormat).ToString(); } else { if (output > 0) { Grid.Rows[index].Cells["Amount"].Value = ClsGlobal.DecimalFormate((_Qty * output), 1, ClsGlobal._AmountDecimalFormat).ToString(); } else { Grid.Rows[index].Cells["Amount"].Value = ClsGlobal.DecimalFormate(0, 1, ClsGlobal._AmountDecimalFormat).ToString(); } } } else if (r["Basis"].ToString().Trim().ToUpper() == "R") { decimal roundoffVal = Convert.ToDecimal(CalTotalForRoundOff()); if (Convert.ToDecimal(roundoffVal.ToString().Split('.').Last()) >= 50) { if (r["Sign"].ToString().Trim() == "+") { decimal a = (1 - Convert.ToDecimal(roundoffVal.ToString().Split('.').Last()) / 100); Grid.Rows[index].Cells["Amount"].Value = ClsGlobal.DecimalFormate(a, 1, ClsGlobal._AmountDecimalFormat).ToString(); } else { Grid.Rows[index].Cells["Amount"].Value = ClsGlobal.DecimalFormate(0, 1, ClsGlobal._AmountDecimalFormat).ToString(); } } else { if (r["Sign"].ToString().Trim() == "-") { decimal b = (Convert.ToDecimal(roundoffVal.ToString().Split('.').Last()) / 100); Grid.Rows[index].Cells["Amount"].Value = ClsGlobal.DecimalFormate(b, 1, ClsGlobal._AmountDecimalFormat).ToString(); } else { Grid.Rows[index].Cells["Amount"].Value = ClsGlobal.DecimalFormate(0, 1, ClsGlobal._AmountDecimalFormat).ToString(); } } } i++; } } #endregion CalTotal(); ClsGlobal.DisableGridColumnsSorting(Grid); }
private void CalTermAmount(int RowPosition, decimal txtBoxGridAmount, string typ) { int k = 1; for (int j = RowPosition + 1; j < Grid.RowCount; j++) { DataGridViewRow r = Grid.Rows[j]; decimal.TryParse(r.Cells["TermRate"].Value.ToString(), out decimal ratepercent); if (ratepercent > 0 && r.Cells["Basis"].Value.ToString().Trim().ToUpper() == "V") { decimal _CalCurrentBasicAmt = CalCurrentBasicAmt(RowPosition + k); if (ratepercent > 0 && Convert.ToDecimal(r.Cells["Amount"].Value.ToString()) > 0) { string formula = r.Cells["Formula"].Value.ToString(); if (string.IsNullOrEmpty(formula.Trim())) { r.Cells["Amount"].Value = ClsGlobal.DecimalFormate((_CalCurrentBasicAmt / 100 * ratepercent), 1, ClsGlobal._AmountDecimalFormat).ToString(); } else { DataTable GridTable = ClsGlobal.GridToDataTable(Grid); DataTable myTable = new DataTable(); myTable = GridTable.Clone(); _CalCurrentBasicAmt = CalBasicAmt4Formula(formula, GridTable, myTable); r.Cells["Amount"].Value = ClsGlobal.DecimalFormate((_CalCurrentBasicAmt / 100 * ratepercent), 1, ClsGlobal._AmountDecimalFormat).ToString(); } } else { r.Cells["Amount"].Value = r.Cells["Amount"].Value.ToString(); } if (k == 1 && typ.Trim().ToUpper() == "A") { TxtGridAmount.Text = ClsGlobal.DecimalFormate((_CalCurrentBasicAmt / 100 * ratepercent), 1, ClsGlobal._AmountDecimalFormat).ToString(); } } else if (ratepercent <= 0 && r.Cells["Basis"].Value.ToString().Trim().ToUpper() == "Q") { if (ratepercent > 0 && Convert.ToDecimal(r.Cells["Amount"].Value.ToString()) > 0) { r.Cells["Amount"].Value = ClsGlobal.DecimalFormate((_Qty * ratepercent), 1, ClsGlobal._AmountDecimalFormat).ToString(); } else { r.Cells["Amount"].Value = r.Cells["Amount"].Value.ToString(); } } else if (r.Cells["Basis"].Value.ToString().Trim().ToUpper() == "R") { decimal roundoffVal = Convert.ToDecimal(CalTotalForRoundOff()); if (Convert.ToDecimal(roundoffVal.ToString().Split('.').Last()) >= 50) { if (r.Cells["Sign"].Value.ToString().Trim() == "+") { decimal a = 1 - Convert.ToDecimal(roundoffVal.ToString().Split('.').Last()) / 100; r.Cells["Amount"].Value = ClsGlobal.DecimalFormate(a, 1, ClsGlobal._AmountDecimalFormat).ToString(); } else { r.Cells["Amount"].Value = ClsGlobal.DecimalFormate(0, 1, ClsGlobal._AmountDecimalFormat).ToString(); } } else { if (r.Cells["Sign"].Value.ToString().Trim() == "-") { decimal b = Convert.ToDecimal(roundoffVal.ToString().Split('.').Last()) / 100; r.Cells["Amount"].Value = ClsGlobal.DecimalFormate(b, 1, ClsGlobal._AmountDecimalFormat).ToString(); } else { r.Cells["Amount"].Value = ClsGlobal.DecimalFormate(0, 1, ClsGlobal._AmountDecimalFormat).ToString(); } } } k++; } CalTotal(); }