/// <summary>
 /// Function to fill datagridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         CurrencySP spCurrency   = new CurrencySP();
         DataTable  dtblCurrency = new DataTable();
         if (txtCurrencyName.Text == string.Empty && txtCurrencySymbol.Text == string.Empty)
         {
             txtCurrencyName.Text   = string.Empty;
             txtCurrencySymbol.Text = string.Empty;
         }
         dtblCurrency           = spCurrency.CurrencySearch(txtCurrencyName.Text, txtCurrencySymbol.Text);
         dgvCurrency.DataSource = dtblCurrency;
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "CDP1:" + ex.Message;
     }
 }
Exemple #2
0
 /// <summary>
 /// Function to fill controls for update
 /// </summary>
 public void FillControls()
 {
     try
     {
         CurrencyInfo infoCurrency = new CurrencyInfo();
         CurrencySP   spCurrency   = new CurrencySP();
         infoCurrency          = spCurrency.CurrencyView(decId);
         txtName.Text          = infoCurrency.CurrencyName;
         txtSymbol.Text        = infoCurrency.CurrencySymbol;
         txtSubUnit.Text       = infoCurrency.SubunitName;
         txtDecimalPlaces.Text = infoCurrency.NoOfDecimalPlaces.ToString();
         txtNarration.Text     = infoCurrency.Narration;
         decCurrencyId         = infoCurrency.CurrencyId;
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "C4:" + ex.Message;
     }
 }
Exemple #3
0
 /// <summary>
 /// Function to fill Currency combobox
 /// </summary>
 public void CurrencyRateComboFill()
 {
     try
     {
         DataTable  dtblCurrencyRate = new DataTable();
         CurrencySP spCurrency       = new CurrencySP();
         dtblCurrencyRate = spCurrency.CurrencyViewAllForCombo();
         DataRow dr = dtblCurrencyRate.NewRow();
         dr[2] = "All";
         dtblCurrencyRate.Rows.InsertAt(dr, 0);
         cmbCurrencyRate.DataSource    = dtblCurrencyRate;
         cmbCurrencyRate.ValueMember   = "currencyId";
         cmbCurrencyRate.DisplayMember = "currencyName";
     }
     catch (Exception ex)
     {
         MessageBox.Show("ER6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill datagridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         CurrencySP spCurrency = new CurrencySP();
         DataTable dtblCurrency = new DataTable();
         if (txtCurrencyName.Text == string.Empty && txtCurrencySymbol.Text == string.Empty)
         {
             txtCurrencyName.Text = string.Empty;
             txtCurrencySymbol.Text = string.Empty;
         }
         dtblCurrency = spCurrency.CurrencySearch(txtCurrencyName.Text, txtCurrencySymbol.Text);
         dgvCurrency.DataSource = dtblCurrency;
     }
     catch (Exception ex)
     {
         MessageBox.Show("CDP1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to return amount in words
 /// </summary>
 /// <param name="decAmount"></param>
 /// <param name="decCurrId"></param>
 /// <returns></returns>
 public string AmountWords(decimal decAmount, decimal decCurrId)
 {
     string AountInWords = string.Empty; // To return the amount in words
     CurrencyInfo currencyInfo = new CurrencySP().CurrencyView(decCurrId);
     decAmount = Math.Round(decAmount, currencyInfo.NoOfDecimalPlaces); //Rounding according to decimal places of currency
     string strAmount = decAmount.ToString(); // Just keeping the whole amount as string for performing split operation on it
     string strAmountinwordsOfIntiger = string.Empty;  // To hold amount in words of intiger
     string strAmountInWordsOfDecimal = string.Empty; // To hold amoutn in words of decimal part
     string[] strPartsArray = strAmount.Split('.'); // Splitting with "." to get intiger part and decimal part seperately
     string strDecimaPart = string.Empty;                     // To hold decimal part
     if (strPartsArray.Length > 1)
         if (strPartsArray[1] != null)
             strDecimaPart = strPartsArray[1]; // Holding decimal portion if any
     if (strPartsArray[0] != null)
         strAmount = strPartsArray[0];    // Holding intiger part of amount
     else
         strAmount = string.Empty; ;
     if (strAmount.Trim() != string.Empty && decimal.Parse(strAmount) != 0)
         strAmountinwordsOfIntiger = NumberToText(long.Parse(strAmount));
     if (strDecimaPart.Trim() != string.Empty && decimal.Parse(strDecimaPart) != 0)
         strAmountInWordsOfDecimal = NumberToText(long.Parse(strDecimaPart));
     SettingsSP spSettings = new SettingsSP();
     if (spSettings.SettingsStatusCheck("ShowCurrencySymbol") != "Yes")
     {
         // Showing currency as suffix
         if (strAmountinwordsOfIntiger != string.Empty)
             AountInWords = strAmountinwordsOfIntiger + " " + currencyInfo.CurrencyName;
         if (strAmountInWordsOfDecimal != string.Empty)
             AountInWords = AountInWords + " and " + strAmountInWordsOfDecimal + " " + currencyInfo.SubunitName;
         AountInWords = AountInWords + " only";
     }
     else
     {
         // Showing currency as prefix
         if (strAmountinwordsOfIntiger != string.Empty)
             AountInWords = currencyInfo.CurrencyName + " " + strAmountinwordsOfIntiger;
         if (strAmountInWordsOfDecimal != string.Empty)
             AountInWords = AountInWords + " and " + currencyInfo.SubunitName + " " + strAmountInWordsOfDecimal;
         AountInWords = AountInWords + " only";
     }
     return AountInWords;
 }
Exemple #6
0
 /// <summary>
 /// Function to delete
 /// </summary>
 public void DeleteFunction()
 {
     try
     {
         CurrencySP spCurrency = new CurrencySP();
         if (spCurrency.CurrencyCheckReferences(decId) == -1)
         {
             Messages.ReferenceExistsMessage();
         }
         else
         {
             Messages.DeletedMessage();
             Clear();
             GridFill();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("C8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #7
0
 /// <summary>
 /// Function to delete
 /// </summary>
 public void DeleteFunction()
 {
     try
     {
         CurrencySP spCurrency = new CurrencySP();
         if (spCurrency.CurrencyCheckReferences(decId) == -1)
         {
             Messages.ReferenceExistsMessage();
         }
         else
         {
             Messages.DeletedMessage();
             Clear();
             GridFill();
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "C8:" + ex.Message;
     }
 }
Exemple #8
0
 /// <summary>
 /// Function to save
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         CurrencyInfo infoCurrency = new CurrencyInfo();
         CurrencySP   spCurrency   = new CurrencySP();
         infoCurrency.CurrencySymbol    = txtSymbol.Text.Trim();
         infoCurrency.CurrencyName      = txtName.Text.Trim();
         infoCurrency.SubunitName       = txtSubUnit.Text.Trim();
         infoCurrency.NoOfDecimalPlaces = Convert.ToInt32(txtDecimalPlaces.Text.Trim());
         infoCurrency.Narration         = txtNarration.Text.Trim();
         infoCurrency.IsDefault         = false;
         infoCurrency.Extra1            = string.Empty;
         infoCurrency.Extra2            = string.Empty;
         if (spCurrency.CurrencyNameCheckExistence(txtName.Text.Trim(), txtSymbol.Text.Trim(), 0) == false)
         {
             decCurrency = spCurrency.CurrencyAddwithIdentity(infoCurrency);
             Messages.SavedMessage();
             Clear();
             decIdForOtherForms = decCurrency;
             if (frmExchangeRateObj != null)
             {
                 this.Close();
             }
         }
         else
         {
             Messages.InformationMessage("Currency name already exist");
             txtName.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("C1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #9
0
 /// <summary>
 /// Function to save
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         CurrencyInfo infoCurrency = new CurrencyInfo();
         CurrencySP spCurrency = new CurrencySP();
         infoCurrency.CurrencySymbol = txtSymbol.Text.Trim();
         infoCurrency.CurrencyName = txtName.Text.Trim();
         infoCurrency.SubunitName = txtSubUnit.Text.Trim();
         infoCurrency.NoOfDecimalPlaces = Convert.ToInt32(txtDecimalPlaces.Text.Trim());
         infoCurrency.Narration = txtNarration.Text.Trim();
         infoCurrency.IsDefault = false;
         infoCurrency.Extra1 = string.Empty;
         infoCurrency.Extra2 = string.Empty;
         if (spCurrency.CurrencyNameCheckExistence(txtName.Text.Trim(),txtSymbol.Text.Trim(),0) == false)
         {
             decCurrency = spCurrency.CurrencyAddwithIdentity(infoCurrency);
             Messages.SavedMessage();
             Clear();
             decIdForOtherForms = decCurrency;
             if (frmExchangeRateObj != null)
             {
                 this.Close();
             }
         }
         else
         {
             Messages.InformationMessage("Currency name already exist");
             txtName.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("C1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// On 'Currency' combobox selected valuechanged
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cmbCurrency_SelectedValueChanged(object sender, EventArgs e)
 {
     try
     {
         CurrencySP SpCurrency = new CurrencySP();
         String strSymbol = SpCurrency.GetDefaultCurrencySymbol();
         pnlExchange.Visible = true;
         lblSymbol.Text = "1" + cmbCurrency.Text;
         lblRate.Text = txtExchangeRate.Text + strSymbol;
     }
     catch (Exception)
     {
         throw;
     }
 }
 /// <summary>
 /// On 'ExchangeRate' textbox textchanged
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtExchangeRate_TextChanged(object sender, EventArgs e)
 {
     try
     {
         CurrencySP SpCurrency = new CurrencySP();
         String strSymbol = SpCurrency.GetDefaultCurrencySymbol();
         pnlExchange.Visible = true;
         lblSymbol.Text = "1" + cmbCurrency.Text;
         lblRate.Text = txtExchangeRate.Text + strSymbol/*"Rs"*/;
     }
     catch (Exception ex)
     {
         MessageBox.Show("ER23:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #12
0
 /// <summary>
 /// Function to fill Datagridview after calculation
 /// </summary>
 public void GridFill()
 {
     try
     {
         if (!isFormLoad)
         {
             DateValidation objValidation = new DateValidation();
             objValidation.DateValidationFunction(txtFundFlowFromDate);
             if (txtFundFlowFromDate.Text == string.Empty)
                 txtFundFlowFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy");
             objValidation.DateValidationFunction(txtFundflowToDate);
             if (txtFundflowToDate.Text == string.Empty)
                 txtFundflowToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
             //-------------------------------------First gridfill-------------------------------------//
             DateTime strFromDate = Convert.ToDateTime(txtFundFlowFromDate.Text.ToString());
             DateTime strTodate = Convert.ToDateTime(txtFundflowToDate.Text.ToString());
             FinancialStatementSP spFinancial = new FinancialStatementSP();
             DataSet dsetFinancial = new DataSet();
             SettingsInfo InfoSettings = new SettingsInfo();
             SettingsSP SpSettings = new SettingsSP();
             //--------------- Selection Of Calculation Method According To Settings ------------------// 
             if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "FIFO")
             {
                 strCalculationMethod = "FIFO";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Average Cost")
             {
                 strCalculationMethod = "Average Cost";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "High Cost")
             {
                 strCalculationMethod = "High Cost";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Low Cost")
             {
                 strCalculationMethod = "Low Cost";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Last Purchase Rate")
             {
                 strCalculationMethod = "Last Purchase Rate";
             }
             dsetFinancial = spFinancial.FundFlow(strFromDate, strTodate);
             DataTable dtbl = new DataTable();
             Font newFont = new Font(dgvFundFlow.Font, FontStyle.Bold);
             CurrencyInfo InfoCurrency = new CurrencyInfo();
             CurrencySP SpCurrency = new CurrencySP();
             InfoCurrency = SpCurrency.CurrencyView(1);
             int inDecimalPlaces = InfoCurrency.NoOfDecimalPlaces;
             dgvFundFlow.Rows.Clear();
             ////-------------------Source--------------------------------------------------------------
             dtbl = dsetFinancial.Tables[0];
             foreach (DataRow rw in dtbl.Rows)
             {
                 dgvFundFlow.Rows.Add();
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtSource"].Value = rw["Name"].ToString();
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = rw["Balance"].ToString();
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtgroupId1"].Value = rw["ID"].ToString();
             }
             decimal dcTotalAsset = 0;
             if (dtbl.Rows.Count > 0)
             {
                 dcTotalAsset = decimal.Parse(dtbl.Compute("Sum(Balance)", string.Empty).ToString());
             }
             ////-----------------Application------------------------------------------------------------
             dtbl = new DataTable();
             dtbl = dsetFinancial.Tables[1];
             int index = 0;
             foreach (DataRow rw in dtbl.Rows)
             {
                 if (index < dgvFundFlow.Rows.Count)
                 {
                     dgvFundFlow.Rows[index].Cells["dgvtxtApplication"].Value = rw["Name"].ToString();
                     dgvFundFlow.Rows[index].Cells["dgvtxtAmount2"].Value = rw["Balance"].ToString();
                     dgvFundFlow.Rows[index].Cells["dgvtxtgroupId2"].Value = rw["ID"].ToString();
                 }
                 else
                 {
                     dgvFundFlow.Rows.Add();
                     dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtApplication"].Value = rw["Name"].ToString();
                     dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = rw["Balance"].ToString();
                     dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtgroupId2"].Value = rw["ID"].ToString();
                 }
                 index++;
             }
             decimal dcTotalLiability = 0;
             if (dtbl.Rows.Count > 0)
             {
                 dcTotalLiability = Convert.ToDecimal(dtbl.Compute("Sum(Balance)", string.Empty).ToString());
             }
             //-------------------- Closing Stock -----------------------//  With Calculation
             dcClosingStock = spFinancial.StockValueGetOnDate(Convert.ToDateTime(txtFundflowToDate.Text), strCalculationMethod, false, false);
             dcClosingStock = Math.Round(dcClosingStock, inDecimalPlaces);
             //---------------------Opening Stock-----------------------
             decimal dcOpeninggStock = spFinancial.StockValueGetOnDate(Convert.ToDateTime(txtFundFlowFromDate.Text), strCalculationMethod, true, false);
             //------------- Profit Or Loss -----------// With Calculation
             decimal dcProfit = 0;
             DataSet dsetProfitAndLoss = new DataSet();
             dsetProfitAndLoss = spFinancial.ProfitAndLossAnalysisUpToaDateForBalansheet(Convert.ToDateTime(txtFundFlowFromDate.Text), Convert.ToDateTime(txtFundflowToDate.Text));
             DataTable dtblProfit = new DataTable();
             dtblProfit = dsetProfitAndLoss.Tables[0];
             for (int i = 0; i < dsetProfitAndLoss.Tables.Count; ++i)
             {
                 dtbl = dsetProfitAndLoss.Tables[i];
                 decimal dcSum = 0;
                 if (i == 0 || (i % 2) == 0)
                 {
                     if (dtbl.Rows.Count > 0)
                     {
                         dcSum = Convert.ToDecimal(dtbl.Compute("Sum(Debit)", string.Empty).ToString());
                         dcProfit = dcProfit - dcSum;
                     }
                 }
                 else
                 {
                     if (dtbl.Rows.Count > 0)
                     {
                         dcSum = Convert.ToDecimal(dtbl.Compute("Sum(Credit)", string.Empty).ToString());
                         dcProfit = dcProfit + dcSum;
                     }
                 }
             }
             //---------------------NetProfit/NetLoss Calculation--------------------------
             dcProfit = dcProfit + dcClosingStock - dcOpeninggStock;
             if (dcProfit > 0)
             {
                 //------------ Liability ------------//
                 dgvFundFlow.Rows.Add();
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtSource"].Value = "Net Profit";
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = Math.Round(dcProfit, inDecimalPlaces);
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtAmount1"].Style.ForeColor = Color.Green;
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtSource"].Style.ForeColor = Color.Green;
                 //dcTotalLiability += dcProfit;
             }
             else
             {
                 //-------------- Asset ---------------//
                 dgvFundFlow.Rows.Add();
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtApplication"].Value = "Net Loss";
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = -Math.Round(dcProfit, inDecimalPlaces);
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtAmount2"].Style.ForeColor = Color.Red;
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtApplication"].Style.ForeColor = Color.Red;
             }
             if (dcProfit > 0)
             {
                 dcTotalAsset += (dcProfit);
             }
             else
             {
                 dcTotalLiability += (-dcProfit);
             }
             decimal dcTotalValue = dcTotalAsset;
             dgvFundFlow.Rows.Add();
             dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = "_______________________";
             dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = "_______________________";
             dgvFundFlow.Rows.Add();
             dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].DefaultCellStyle.Font = newFont;
             dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtApplication"].Value = "Total";
             dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtSource"].Value = "Total";
             dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = Math.Round((dcTotalAsset), inDecimalPlaces);
             dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = Math.Round((dcTotalLiability), inDecimalPlaces);
             //----------------------------------------Second gridfill----------------------------------------------
             //--------------------------------------Current Assets-------------------------------------------
             Font newFont2 = new Font(dgvFundFlow2.Font, FontStyle.Bold);
             dgvFundFlow2.Rows.Clear();
             dtbl = dsetFinancial.Tables[3];
             decimal decWC = 0;
             foreach (DataRow rw in dtbl.Rows)
             {
                 dgvFundFlow2.Rows.Add();
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtgroupId"].Value = rw["ID"].ToString();
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtParticulars"].Value = rw["Name"].ToString();
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtOpeningBalance"].Value = rw["OpeningBalance"].ToString() + "Dr";
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtop"].Value = rw["OpeningBalance"].ToString();
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtcb"].Value = rw["ClosingBalance"].ToString();
                 decimal decOB = Convert.ToDecimal(rw["OpeningBalance"].ToString());
                 decimal decCB = Convert.ToDecimal(rw["ClosingBalance"].ToString());
                 decCB = decCB + dcClosingStock;
                 if (decCB > 0)
                 {
                     dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtClosingBalance"].Value = Math.Round(decCB, inDecimalPlaces).ToString() + "Dr";
                     dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtcb"].Value = Math.Round(decCB, inDecimalPlaces).ToString();
                 }
                 else
                 {
                     decCB = -1 * decCB;
                     dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtClosingBalance"].Value = Math.Round(decCB, inDecimalPlaces).ToString() + "Dr";
                     dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtcb"].Value = Math.Round(decCB, inDecimalPlaces).ToString();
                 }
                 decWC = decOB - decCB;
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtWorkingCapitalIncrease"].Value = Math.Round(decWC, inDecimalPlaces).ToString();
             }
             //--------------------------------------Current Liability-------------------------------------------
             dtbl = dsetFinancial.Tables[5];
             decimal decWCCL = 0;
             foreach (DataRow rw in dtbl.Rows)
             {
                 dgvFundFlow2.Rows.Add();
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtgroupId"].Value = rw["ID"].ToString();
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtParticulars"].Value = rw["Name"].ToString();
                 decimal decOp = Convert.ToDecimal(rw["OpeningBalance"].ToString());
                 decimal decCb = Convert.ToDecimal(rw["ClosingBalance"].ToString());
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtOpeningBalance"].Value = decOp.ToString() + "Cr";
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtop"].Value = rw["OpeningBalance"].ToString();
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtcb"].Value = rw["ClosingBalance"].ToString();
                 if (decCb > 0)
                 {
                     dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtClosingBalance"].Value = decCb.ToString() + "Cr";
                     dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtcb"].Value = decCb.ToString();
                 }
                 else
                 {
                     decCb = -1 * decCb;
                     dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtClosingBalance"].Value = decCb.ToString() + "Cr";
                     dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtcb"].Value = decCb.ToString();
                 }
                 decimal decOB = Convert.ToDecimal(rw["OpeningBalance"].ToString());
                 decimal decCB = Convert.ToDecimal(rw["ClosingBalance"].ToString());
                 decWCCL = decOp - decCb;
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtWorkingCapitalIncrease"].Value = decWCCL.ToString();
             }
             //-----------------Calculating Working capital---------------
             decimal decOpen = 0;
             decimal decClose = 0;
             decimal decWork = 0;
             decOpen = Convert.ToDecimal(dgvFundFlow2.Rows[0].Cells[3].Value.ToString()) - Convert.ToDecimal(dgvFundFlow2.Rows[1].Cells[3].Value.ToString());
             decClose = Convert.ToDecimal(dgvFundFlow2.Rows[0].Cells[5].Value.ToString()) - Convert.ToDecimal(dgvFundFlow2.Rows[1].Cells[5].Value.ToString());
             decWork = Convert.ToDecimal(dgvFundFlow2.Rows[0].Cells[6].Value.ToString()) - Convert.ToDecimal(dgvFundFlow2.Rows[1].Cells[6].Value.ToString());
             decimal decW1 = Convert.ToDecimal(dgvFundFlow2.Rows[0].Cells[6].Value.ToString());
             decimal decW2 = Convert.ToDecimal(dgvFundFlow2.Rows[1].Cells[6].Value.ToString());
             dgvFundFlow2.Rows.Add();
             dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtParticulars"].Value = "Working Capital";
             if (decOpen > 0)
             {
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtOpeningBalance"].Value = decOpen.ToString() + "Dr";
             }
             else
             {
                 decOpen *= -1;
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtOpeningBalance"].Value = decOpen.ToString() + "Cr";
             }
             if (decClose > 0)
             {
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtClosingBalance"].Value = decClose.ToString() + "Dr";
             }
             else
             {
                 decClose *= -1;
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtClosingBalance"].Value = decClose.ToString() + "Cr";
             }
             dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtWorkingCapitalIncrease"].Value = decWork.ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("FF:06" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #13
0
 /// <summary>
 /// Function to Edit
 /// </summary>
 public void EditFunction()
 {
     try
     {
         CurrencyInfo infoCurrency = new CurrencyInfo();
         CurrencySP spCurrency = new CurrencySP();
         infoCurrency.CurrencySymbol = txtSymbol.Text.Trim();
         infoCurrency.CurrencyName = txtName.Text.Trim();
         infoCurrency.SubunitName = txtSubUnit.Text.Trim();
         infoCurrency.NoOfDecimalPlaces = Convert.ToInt32(txtDecimalPlaces.Text.Trim());
         infoCurrency.Narration = txtNarration.Text.Trim();
         infoCurrency.IsDefault = false;
         infoCurrency.Extra1 = String.Empty;
         infoCurrency.Extra2 = String.Empty;
         infoCurrency.CurrencyId = decId;
         if (spCurrency.CurrencyNameCheckExistence(txtName.Text.Trim(), txtSymbol.Text.Trim(), decCurrencyId) == false)
         {
             spCurrency.CurrencyEdit(infoCurrency);
             Messages.UpdatedMessage();
             SearchClear();
             Clear();
         }
         else
         {
             Messages.InformationMessage("Currency name already exist");
             txtName.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("C2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #14
0
 /// <summary>
 /// Function to fill Datagridview after calculation
 /// </summary>
 public void GridFill()
 {
     try
     {
         if (!isFormLoad)
         {
             DateValidation objValidation = new DateValidation();
             objValidation.DateValidationFunction(txtFundFlowFromDate);
             if (txtFundFlowFromDate.Text == string.Empty)
             {
                 txtFundFlowFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy");
             }
             objValidation.DateValidationFunction(txtFundflowToDate);
             if (txtFundflowToDate.Text == string.Empty)
             {
                 txtFundflowToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
             }
             //-------------------------------------First gridfill-------------------------------------//
             DateTime             strFromDate = Convert.ToDateTime(txtFundFlowFromDate.Text.ToString());
             DateTime             strTodate   = Convert.ToDateTime(txtFundflowToDate.Text.ToString());
             FinancialStatementSP spFinancial = new FinancialStatementSP();
             DataSet      dsetFinancial       = new DataSet();
             SettingsInfo InfoSettings        = new SettingsInfo();
             SettingsSP   SpSettings          = new SettingsSP();
             //--------------- Selection Of Calculation Method According To Settings ------------------//
             if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "FIFO")
             {
                 strCalculationMethod = "FIFO";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Average Cost")
             {
                 strCalculationMethod = "Average Cost";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "High Cost")
             {
                 strCalculationMethod = "High Cost";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Low Cost")
             {
                 strCalculationMethod = "Low Cost";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Last Purchase Rate")
             {
                 strCalculationMethod = "Last Purchase Rate";
             }
             dsetFinancial = spFinancial.FundFlow(strFromDate, strTodate);
             DataTable    dtbl         = new DataTable();
             Font         newFont      = new Font(dgvFundFlow.Font, FontStyle.Bold);
             CurrencyInfo InfoCurrency = new CurrencyInfo();
             CurrencySP   SpCurrency   = new CurrencySP();
             InfoCurrency = SpCurrency.CurrencyView(1);
             int inDecimalPlaces = InfoCurrency.NoOfDecimalPlaces;
             dgvFundFlow.Rows.Clear();
             ////-------------------Source--------------------------------------------------------------
             dtbl = dsetFinancial.Tables[0];
             foreach (DataRow rw in dtbl.Rows)
             {
                 dgvFundFlow.Rows.Add();
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtSource"].Value   = rw["Name"].ToString();
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtAmount1"].Value  = rw["Balance"].ToString();
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtgroupId1"].Value = rw["ID"].ToString();
             }
             decimal dcTotalAsset = 0;
             if (dtbl.Rows.Count > 0)
             {
                 dcTotalAsset = decimal.Parse(dtbl.Compute("Sum(Balance)", string.Empty).ToString());
             }
             ////-----------------Application------------------------------------------------------------
             dtbl = new DataTable();
             dtbl = dsetFinancial.Tables[1];
             int index = 0;
             foreach (DataRow rw in dtbl.Rows)
             {
                 if (index < dgvFundFlow.Rows.Count)
                 {
                     dgvFundFlow.Rows[index].Cells["dgvtxtApplication"].Value = rw["Name"].ToString();
                     dgvFundFlow.Rows[index].Cells["dgvtxtAmount2"].Value     = rw["Balance"].ToString();
                     dgvFundFlow.Rows[index].Cells["dgvtxtgroupId2"].Value    = rw["ID"].ToString();
                 }
                 else
                 {
                     dgvFundFlow.Rows.Add();
                     dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtApplication"].Value = rw["Name"].ToString();
                     dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtAmount2"].Value     = rw["Balance"].ToString();
                     dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtgroupId2"].Value    = rw["ID"].ToString();
                 }
                 index++;
             }
             decimal dcTotalLiability = 0;
             if (dtbl.Rows.Count > 0)
             {
                 dcTotalLiability = Convert.ToDecimal(dtbl.Compute("Sum(Balance)", string.Empty).ToString());
             }
             //-------------------- Closing Stock -----------------------//  With Calculation
             dcClosingStock = spFinancial.StockValueGetOnDate(Convert.ToDateTime(txtFundflowToDate.Text), strCalculationMethod, false, false);
             dcClosingStock = Math.Round(dcClosingStock, inDecimalPlaces);
             //---------------------Opening Stock-----------------------
             decimal dcOpeninggStock = spFinancial.StockValueGetOnDate(Convert.ToDateTime(txtFundFlowFromDate.Text), strCalculationMethod, true, false);
             //------------- Profit Or Loss -----------// With Calculation
             decimal dcProfit          = 0;
             DataSet dsetProfitAndLoss = new DataSet();
             dsetProfitAndLoss = spFinancial.ProfitAndLossAnalysisUpToaDateForBalansheet(Convert.ToDateTime(txtFundFlowFromDate.Text), Convert.ToDateTime(txtFundflowToDate.Text));
             DataTable dtblProfit = new DataTable();
             dtblProfit = dsetProfitAndLoss.Tables[0];
             for (int i = 0; i < dsetProfitAndLoss.Tables.Count; ++i)
             {
                 dtbl = dsetProfitAndLoss.Tables[i];
                 decimal dcSum = 0;
                 if (i == 0 || (i % 2) == 0)
                 {
                     if (dtbl.Rows.Count > 0)
                     {
                         dcSum    = Convert.ToDecimal(dtbl.Compute("Sum(Debit)", string.Empty).ToString());
                         dcProfit = dcProfit - dcSum;
                     }
                 }
                 else
                 {
                     if (dtbl.Rows.Count > 0)
                     {
                         dcSum    = Convert.ToDecimal(dtbl.Compute("Sum(Credit)", string.Empty).ToString());
                         dcProfit = dcProfit + dcSum;
                     }
                 }
             }
             //---------------------NetProfit/NetLoss Calculation--------------------------
             dcProfit = dcProfit + dcClosingStock - dcOpeninggStock;
             if (dcProfit > 0)
             {
                 //------------ Liability ------------//
                 dgvFundFlow.Rows.Add();
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtSource"].Value            = "Net Profit";
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtAmount1"].Value           = Math.Round(dcProfit, inDecimalPlaces);
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtAmount1"].Style.ForeColor = Color.Green;
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtSource"].Style.ForeColor  = Color.Green;
                 //dcTotalLiability += dcProfit;
             }
             else
             {
                 //-------------- Asset ---------------//
                 dgvFundFlow.Rows.Add();
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtApplication"].Value           = "Net Loss";
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtAmount2"].Value               = -Math.Round(dcProfit, inDecimalPlaces);
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtAmount2"].Style.ForeColor     = Color.Red;
                 dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtApplication"].Style.ForeColor = Color.Red;
             }
             if (dcProfit > 0)
             {
                 dcTotalAsset += (dcProfit);
             }
             else
             {
                 dcTotalLiability += (-dcProfit);
             }
             decimal dcTotalValue = dcTotalAsset;
             dgvFundFlow.Rows.Add();
             dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = "_______________________";
             dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = "_______________________";
             dgvFundFlow.Rows.Add();
             dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].DefaultCellStyle.Font            = newFont;
             dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtApplication"].Value = "Total";
             dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtSource"].Value      = "Total";
             dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtAmount1"].Value     = Math.Round((dcTotalAsset), inDecimalPlaces);
             dgvFundFlow.Rows[dgvFundFlow.Rows.Count - 1].Cells["dgvtxtAmount2"].Value     = Math.Round((dcTotalLiability), inDecimalPlaces);
             //----------------------------------------Second gridfill----------------------------------------------
             //--------------------------------------Current Assets-------------------------------------------
             Font newFont2 = new Font(dgvFundFlow2.Font, FontStyle.Bold);
             dgvFundFlow2.Rows.Clear();
             dtbl = dsetFinancial.Tables[3];
             decimal decWC = 0;
             foreach (DataRow rw in dtbl.Rows)
             {
                 dgvFundFlow2.Rows.Add();
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtgroupId"].Value        = rw["ID"].ToString();
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtParticulars"].Value    = rw["Name"].ToString();
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtOpeningBalance"].Value = rw["OpeningBalance"].ToString() + "Dr";
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtop"].Value             = rw["OpeningBalance"].ToString();
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtcb"].Value             = rw["ClosingBalance"].ToString();
                 decimal decOB = Convert.ToDecimal(rw["OpeningBalance"].ToString());
                 decimal decCB = Convert.ToDecimal(rw["ClosingBalance"].ToString());
                 decCB = decCB + dcClosingStock;
                 if (decCB > 0)
                 {
                     dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtClosingBalance"].Value = Math.Round(decCB, inDecimalPlaces).ToString() + "Dr";
                     dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtcb"].Value             = Math.Round(decCB, inDecimalPlaces).ToString();
                 }
                 else
                 {
                     decCB = -1 * decCB;
                     dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtClosingBalance"].Value = Math.Round(decCB, inDecimalPlaces).ToString() + "Dr";
                     dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtcb"].Value             = Math.Round(decCB, inDecimalPlaces).ToString();
                 }
                 decWC = decOB - decCB;
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtWorkingCapitalIncrease"].Value = Math.Round(decWC, inDecimalPlaces).ToString();
             }
             //--------------------------------------Current Liability-------------------------------------------
             dtbl = dsetFinancial.Tables[5];
             decimal decWCCL = 0;
             foreach (DataRow rw in dtbl.Rows)
             {
                 dgvFundFlow2.Rows.Add();
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtgroupId"].Value     = rw["ID"].ToString();
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtParticulars"].Value = rw["Name"].ToString();
                 decimal decOp = Convert.ToDecimal(rw["OpeningBalance"].ToString());
                 decimal decCb = Convert.ToDecimal(rw["ClosingBalance"].ToString());
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtOpeningBalance"].Value = decOp.ToString() + "Cr";
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtop"].Value             = rw["OpeningBalance"].ToString();
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtcb"].Value             = rw["ClosingBalance"].ToString();
                 if (decCb > 0)
                 {
                     dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtClosingBalance"].Value = decCb.ToString() + "Cr";
                     dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtcb"].Value             = decCb.ToString();
                 }
                 else
                 {
                     decCb = -1 * decCb;
                     dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtClosingBalance"].Value = decCb.ToString() + "Cr";
                     dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtcb"].Value             = decCb.ToString();
                 }
                 decimal decOB = Convert.ToDecimal(rw["OpeningBalance"].ToString());
                 decimal decCB = Convert.ToDecimal(rw["ClosingBalance"].ToString());
                 decWCCL = decOp - decCb;
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtWorkingCapitalIncrease"].Value = decWCCL.ToString();
             }
             //-----------------Calculating Working capital---------------
             decimal decOpen  = 0;
             decimal decClose = 0;
             decimal decWork  = 0;
             decOpen  = Convert.ToDecimal(dgvFundFlow2.Rows[0].Cells[3].Value.ToString()) - Convert.ToDecimal(dgvFundFlow2.Rows[1].Cells[3].Value.ToString());
             decClose = Convert.ToDecimal(dgvFundFlow2.Rows[0].Cells[5].Value.ToString()) - Convert.ToDecimal(dgvFundFlow2.Rows[1].Cells[5].Value.ToString());
             decWork  = Convert.ToDecimal(dgvFundFlow2.Rows[0].Cells[6].Value.ToString()) - Convert.ToDecimal(dgvFundFlow2.Rows[1].Cells[6].Value.ToString());
             decimal decW1 = Convert.ToDecimal(dgvFundFlow2.Rows[0].Cells[6].Value.ToString());
             decimal decW2 = Convert.ToDecimal(dgvFundFlow2.Rows[1].Cells[6].Value.ToString());
             dgvFundFlow2.Rows.Add();
             dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtParticulars"].Value = "Working Capital";
             if (decOpen > 0)
             {
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtOpeningBalance"].Value = decOpen.ToString() + "Dr";
             }
             else
             {
                 decOpen *= -1;
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtOpeningBalance"].Value = decOpen.ToString() + "Cr";
             }
             if (decClose > 0)
             {
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtClosingBalance"].Value = decClose.ToString() + "Dr";
             }
             else
             {
                 decClose *= -1;
                 dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtClosingBalance"].Value = decClose.ToString() + "Cr";
             }
             dgvFundFlow2.Rows[dgvFundFlow2.Rows.Count - 1].Cells["dgvtxtWorkingCapitalIncrease"].Value = decWork.ToString();
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "FF6:" + ex.Message;
     }
 }
Exemple #15
0
 /// <summary>
 /// On datagridview cell double click
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvCurrency_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     CurrencySP spCurrency = new CurrencySP();
     try
     {
         if (e.RowIndex != -1)
         {
             decId = Convert.ToDecimal(dgvCurrency.Rows[e.RowIndex].Cells["dgvtxtCurrencyId"].Value.ToString());
             if (!spCurrency.DefaultCurrencyCheck(decId))
             {
                 FillControls();
                 btnDelete.Enabled = true;
                 btnSave.Text = "Update";
                 txtName.Focus();
             }
             else
             {
                 Messages.InformationMessage("Default currency cannot update or delete");
                 Clear();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("C17:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #16
0
 /// <summary>
 /// Function to fill datagridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         CurrencySP spCurrency = new CurrencySP();
         DataTable dtblCurrency = new DataTable();
         dtblCurrency = spCurrency.CurrencySearch(txtNameSearch.Text.Trim(), txtSymbolSearch.Text.Trim());
         dgvCurrency.DataSource = dtblCurrency;
     }
     catch (Exception ex)
     {
         MessageBox.Show("C7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #17
0
        /// <summary>
        /// Export the Barcodes to PDF format here
        /// </summary>
        public void ExportToPDF()
        {
            iTextSharp.text.Document pdfdoc = new iTextSharp.text.Document();
            try
            {
                DirectoryInfo dir1 = new DirectoryInfo(Application.StartupPath + "\\Barcode");
                if (!Directory.Exists(Application.StartupPath + "\\Barcode"))
                {
                    dir1.Create();
                }
                if (File.Exists(Application.StartupPath + "\\Barcode\\Barcode.pdf"))
                {
                    File.Delete(Application.StartupPath + "\\Barcode\\Barcode.pdf");
                }
                pdfdoc = new Document(PageSize.A4, 12, 1, 20, 20);
                PdfWriter writer = PdfWriter.GetInstance(pdfdoc, new FileStream(Application.StartupPath + "\\Barcode\\Barcode.pdf", FileMode.Create));
                PdfPTable tbl    = new PdfPTable(5); // assigning 5 columns to pdf
                tbl.WidthPercentage    = 100;
                tbl.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
                tbl.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
                tbl.DefaultCell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                pdfdoc.Open();
                int intotalCount         = 0;
                BarcodeSettingsInfo Info = new BarcodeSettingsInfo();
                Info = spBarcodeSettings.BarcodeSettingsViewForBarCodePrinting();
                for (int i = 0; i < dgvBarcodePrinting.Rows.Count; i++) // iterating grid to take each product
                {
                    if (dgvBarcodePrinting.Rows[i].Cells["dgvProductCode"].Value != null && dgvBarcodePrinting.Rows[i].Cells["dgvProductCode"].Value.ToString() != "")
                    {
                        int inCopies = 0;
                        if (dgvBarcodePrinting.Rows[i].Cells["dgvCopies"].Value != null)
                        {
                            int.TryParse(dgvBarcodePrinting.Rows[i].Cells["dgvCopies"].Value.ToString(), out inCopies); // number of copies of arcode to be printed
                        }
                        for (int j = 0; j < inCopies; j++)
                        {
                            string strCode = dgvBarcodePrinting.Rows[i].Cells["dgvBarcode"].Value.ToString();
                            // checking settings----------------------------------------------------------------------------------------------------------

                            string strCompanyName = " ";
                            if (Info.ShowCompanyName)
                            {
                                strCompanyName = Info.CompanyName;
                            }
                            //-----------------------------------
                            string strProductCode = " ";
                            if (Info.ShowProductCode)
                            {
                                strProductCode = strCode;
                            }
                            else
                            {
                                strProductCode = dgvBarcodePrinting.Rows[i].Cells["dgvproductName"].Value.ToString();
                            }
                            //-----------------------------------
                            string strMRP = " ";
                            if (Info.ShowMRP)
                            {
                                strMRP = new CurrencySP().CurrencyView(PublicVariables._decCurrencyId).CurrencySymbol + ": " + dgvBarcodePrinting.Rows[i].Cells["dgvMRP"].Value.ToString();
                            }
                            //-----------------------------------
                            string strSecretPurchaseRateCode = " ";
                            if (Info.ShowPurchaseRate)
                            {
                                string strPurchaseRate = dgvBarcodePrinting.Rows[i].Cells["dgvPurchaseRate"].Value.ToString();
                                //converting to secret code
                                if (strPurchaseRate.Contains("."))
                                {
                                    strPurchaseRate = strPurchaseRate.TrimEnd('0');
                                    if (strPurchaseRate[strPurchaseRate.Length - 1] == '.')
                                    {
                                        strPurchaseRate = strPurchaseRate.Replace(".", "");
                                    }
                                }
                                for (int k = 0; k < strPurchaseRate.Length; k++)
                                {
                                    switch (strPurchaseRate[k])
                                    {
                                    case '0':
                                        strSecretPurchaseRateCode += Info.Zero;
                                        break;

                                    case '1':
                                        strSecretPurchaseRateCode += Info.One;
                                        break;

                                    case '2':
                                        strSecretPurchaseRateCode += Info.Two;
                                        break;

                                    case '3':
                                        strSecretPurchaseRateCode += Info.Three;
                                        break;

                                    case '4':
                                        strSecretPurchaseRateCode += Info.Four;
                                        break;

                                    case '5':
                                        strSecretPurchaseRateCode += Info.Five;
                                        break;

                                    case '6':
                                        strSecretPurchaseRateCode += Info.Six;
                                        break;

                                    case '7':
                                        strSecretPurchaseRateCode += Info.Seven;
                                        break;

                                    case '8':
                                        strSecretPurchaseRateCode += Info.Eight;
                                        break;

                                    case '9':
                                        strSecretPurchaseRateCode += Info.Nine;
                                        break;

                                    case '.':
                                        strSecretPurchaseRateCode += Info.Point;
                                        break;
                                    }
                                }
                            }

                            // generating and assigning barcode to PDF

                            PdfContentByte pdfcb   = writer.DirectContent;
                            Barcode128     code128 = new Barcode128();
                            code128.Code          = strCode;
                            code128.Extended      = false;
                            code128.CodeType      = iTextSharp.text.pdf.Barcode.CODE128;
                            code128.AltText       = strProductCode;
                            code128.BarHeight     = 13;
                            code128.Size          = 6;
                            code128.Baseline      = 8;
                            code128.TextAlignment = Element.ALIGN_CENTER;
                            iTextSharp.text.Image image128 = code128.CreateImageWithBarcode(pdfcb, null, null);


                            Phrase phrase = new Phrase();
                            phrase.Font.Size = 8;
                            phrase.Add(new Chunk(strCompanyName + Environment.NewLine + Environment.NewLine));
                            PdfPCell cell = new PdfPCell(phrase);
                            cell.FixedHeight         = 61.69f;
                            cell.HorizontalAlignment = Element.ALIGN_CENTER;
                            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                            cell.Border = iTextSharp.text.Rectangle.NO_BORDER;
                            phrase.Add(new Chunk(image128, 0, 0));
                            phrase.Add(new Chunk(Environment.NewLine + strMRP));
                            phrase.Add(new Chunk(Environment.NewLine + strSecretPurchaseRateCode));
                            tbl.AddCell(cell);
                            intotalCount++; // getting total number of barcode generated
                        }
                    }
                }
                // so we assign a null values to reaming columns
                int reminder = intotalCount % 5;
                if (reminder != 0)
                {
                    for (int i = reminder; i < 5; ++i)
                    {
                        tbl.AddCell("");
                    }
                }
                if (tbl.Rows.Count != 0)
                {
                    pdfdoc.Add(tbl);
                    pdfdoc.Close();
                    System.Diagnostics.Process.Start(Application.StartupPath + "\\Barcode\\Barcode.pdf");
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("The process cannot access the file") && ex.Message.Contains("Barcode.pdf' because it is being used by another process."))
                {
                    MessageBox.Show("Close the PDF file and try again", "Openmiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("BCD4:" + ex.Message, "Openmiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            finally
            {
                try
                {
                    pdfdoc.Close();
                }
                catch
                {
                }
            }
        }
Exemple #18
0
        /// <summary>
        /// Function to fill Datagridview
        /// </summary>
        public void FillGrid()
        {
            try
            {
                if (!isFormLoad)
                {
                    DateValidation objValidation = new DateValidation();
                    objValidation.DateValidationFunction(txtToDate);
                    if (txtToDate.Text == string.Empty)
                    {
                        txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
                    }
                    Font         newFont      = new Font(dgvReport.Font, FontStyle.Bold);
                    CurrencyInfo InfoCurrency = new CurrencyInfo();
                    CurrencySP   SpCurrency   = new CurrencySP();
                    InfoCurrency = SpCurrency.CurrencyView(1);
                    int inDecimalPlaces = InfoCurrency.NoOfDecimalPlaces;
                    dgvReport.Rows.Clear();
                    FinancialStatementSP SpFinance = new FinancialStatementSP();
                    DataSet      DsetBalanceSheet  = new DataSet();
                    DataTable    dtbl         = new DataTable();
                    SettingsInfo InfoSettings = new SettingsInfo();
                    SettingsSP   SpSettings   = new SettingsSP();
                    //--------------- Selection Of Calculation Method According To Settings ------------------//
                    if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "FIFO")
                    {
                        calculationMethod = "FIFO";
                    }
                    else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Average Cost")
                    {
                        calculationMethod = "Average Cost";
                    }
                    else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "High Cost")
                    {
                        calculationMethod = "High Cost";
                    }
                    else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Low Cost")
                    {
                        calculationMethod = "Low Cost";
                    }
                    else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Last Purchase Rate")
                    {
                        calculationMethod = "Last Purchase Rate";
                    }

                    int     LiabilityRow     = 0;
                    int     AssetRow         = 0;
                    decimal TotalAssets      = 0;
                    decimal TotalLiabilities = 0;
                    decimal OpeningStock     = SpFinance.StockValueGetOnDate(Convert.ToDateTime(txtToDate.Text), calculationMethod, true, true);
                    OpeningStock     = Math.Round(OpeningStock, inDecimalPlaces);
                    DsetBalanceSheet = SpFinance.BalanceSheet(PublicVariables._dtFromDate, DateTime.Parse(txtToDate.Text));
                    //------------------- Asset -------------------------------//
                    dtbl = DsetBalanceSheet.Tables[0];
                    foreach (DataRow rw in dtbl.Rows)
                    {
                        dgvReport.Rows.Add();
                        decimal balance = (rw["ID"].ToString() == "6") ? Convert.ToDecimal(rw["Balance"].ToString()) + OpeningStock : Convert.ToDecimal(rw["Balance"].ToString());
                        if (balance > 0)
                        {
                            dgvReport.Rows[AssetRow].Cells["dgvtxtAsset"].Value = rw["Name"].ToString();
                            dgvReport.Rows[AssetRow].Cells["Amount1"].Value     = balance.ToString("N2");
                            dgvReport.Rows[AssetRow].Cells["GroupId1"].Value    = rw["ID"].ToString();
                            TotalAssets += balance;
                            AssetRow++;
                        }
                        else
                        {
                            balance = balance * -1;
                            dgvReport.Rows.Add();
                            dgvReport.Rows[LiabilityRow].Cells["dgvtxtLiability"].Value = rw["Name"].ToString();
                            dgvReport.Rows[LiabilityRow].Cells["Amount2"].Value         = balance.ToString("N2");
                            dgvReport.Rows[LiabilityRow].Cells["GroupId2"].Value        = rw["ID"].ToString();
                            TotalLiabilities += balance;
                            LiabilityRow++;
                        }
                    }

                    //------------------------ Liability ---------------------//
                    dtbl = DsetBalanceSheet.Tables[1];
                    foreach (DataRow rw in dtbl.Rows)
                    {
                        decimal balance = Convert.ToDecimal(rw["Balance"].ToString());
                        if (balance < 0)
                        {
                            balance = balance * -1;
                            dgvReport.Rows.Add();
                            dgvReport.Rows[AssetRow].Cells["dgvtxtAsset"].Value = rw["Name"].ToString();
                            dgvReport.Rows[AssetRow].Cells["Amount1"].Value     = balance.ToString("N2");
                            dgvReport.Rows[AssetRow].Cells["GroupId1"].Value    = rw["ID"].ToString();
                            TotalAssets += balance;
                            AssetRow++;
                        }
                        else
                        {
                            dgvReport.Rows.Add();
                            dgvReport.Rows[LiabilityRow].Cells["dgvtxtLiability"].Value = rw["Name"].ToString();
                            dgvReport.Rows[LiabilityRow].Cells["Amount2"].Value         = balance.ToString("N2");
                            dgvReport.Rows[LiabilityRow].Cells["GroupId2"].Value        = rw["ID"].ToString();
                            TotalLiabilities += balance;
                            LiabilityRow++;
                        }
                    }

                    //---------------------Closing Stock---------------------------------------------------------------------------------------------------------------

                    decimal ClosingStock = SpFinance.StockValueGetOnDate(Convert.ToDateTime(txtToDate.Text), calculationMethod, false, false);
                    ClosingStock = Math.Round(ClosingStock, inDecimalPlaces) - OpeningStock;
                    if (ClosingStock != 0)
                    {
                        if (ClosingStock > 0)
                        {
                            dgvReport.Rows.Add();
                            dgvReport.Rows[AssetRow].Cells["dgvtxtAsset"].Value = "Closing Stock";
                            dgvReport.Rows[AssetRow].Cells["Amount1"].Value     = ClosingStock.ToString("N2");
                            TotalAssets += ClosingStock;
                            AssetRow++;
                        }
                        else
                        {
                            ClosingStock = ClosingStock * -1;
                            dgvReport.Rows.Add();
                            dgvReport.Rows[LiabilityRow].Cells["dgvtxtLiability"].Value = "Closing Stock";
                            dgvReport.Rows[LiabilityRow].Cells["Amount2"].Value         = ClosingStock.ToString("N2");
                            TotalLiabilities += ClosingStock;
                            LiabilityRow++;
                        }
                    }

                    if (AssetRow > LiabilityRow)
                    {
                        LiabilityRow = AssetRow;
                    }
                    else
                    {
                        AssetRow = LiabilityRow;
                    }
                    //---------------------Profit And Loss---------------------------------------------------------------------------------------------------------------

                    DataSet dsetProfitAndLoss = SpFinance.ProfitAndLossAnalysisUpToaDateForBalansheet(PublicVariables._dtFromDate, DateTime.Parse(txtToDate.Text));
                    decimal dcProfit          = 0;
                    for (int i = 0; i < dsetProfitAndLoss.Tables.Count; ++i)
                    {
                        dtbl = dsetProfitAndLoss.Tables[i];
                        decimal dcSum = 0;
                        if (i == 0 || (i % 2) == 0)
                        {
                            if (dtbl.Rows.Count > 0)
                            {
                                dcSum    = decimal.Parse(dtbl.Compute("Sum(Debit)", string.Empty).ToString());
                                dcProfit = dcProfit - dcSum;
                            }
                        }
                        else
                        {
                            if (dtbl.Rows.Count > 0)
                            {
                                dcSum    = decimal.Parse(dtbl.Compute("Sum(Credit)", string.Empty).ToString());
                                dcProfit = dcProfit + dcSum;
                            }
                        }
                    }

                    DataSet dsetProfitAndLossOpening = SpFinance.ProfitAndLossAnalysisUpToaDateForPreviousYears(PublicVariables._dtFromDate);
                    decimal dcProfitOpening          = 0;
                    for (int i = 0; i < dsetProfitAndLossOpening.Tables.Count; ++i)
                    {
                        dtbl = dsetProfitAndLossOpening.Tables[i];
                        decimal dcSum = 0;
                        if (i == 0 || (i % 2) == 0)
                        {
                            if (dtbl.Rows.Count > 0)
                            {
                                dcSum           = decimal.Parse(dtbl.Compute("Sum(Debit)", string.Empty).ToString());
                                dcProfitOpening = dcProfitOpening - dcSum;
                            }
                        }
                        else
                        {
                            if (dtbl.Rows.Count > 0)
                            {
                                dcSum           = decimal.Parse(dtbl.Compute("Sum(Credit)", string.Empty).ToString());
                                dcProfitOpening = dcProfitOpening + dcSum;
                            }
                        }
                    }

                    decimal decProfitLedgerOpening = decimal.Parse(DsetBalanceSheet.Tables[3].Compute("Sum(Balance)", string.Empty).ToString());

                    decimal decTotalProfitAndLoss = decimal.Parse(DsetBalanceSheet.Tables[2].Compute("Sum(Balance)", string.Empty).ToString());

                    decimal decCurrentProfitLoss         = dcProfit + ClosingStock;
                    decimal decOpeningOfProfitAndLoss    = decProfitLedgerOpening + dcProfitOpening;
                    decimal decTotalProfitAndLossOverAll = decTotalProfitAndLoss + decOpeningOfProfitAndLoss + decCurrentProfitLoss;
                    decTotalProfitAndLoss     = (decTotalProfitAndLoss < 0) ? decTotalProfitAndLoss * -1 : decTotalProfitAndLoss;
                    decOpeningOfProfitAndLoss = (decOpeningOfProfitAndLoss < 0) ? decOpeningOfProfitAndLoss * -1 : decOpeningOfProfitAndLoss;
                    decCurrentProfitLoss      = (decCurrentProfitLoss < 0) ? decCurrentProfitLoss * -1 : decCurrentProfitLoss;

                    if (decTotalProfitAndLossOverAll >= 0)
                    {
                        dgvReport.Rows.Add();
                        dgvReport.Rows[AssetRow].Cells["dgvtxtAsset"].Value = "----------------------------------------";
                        dgvReport.Rows[AssetRow].DefaultCellStyle.Font      = newFont;
                        AssetRow++;
                        foreach (DataRow dRow in DsetBalanceSheet.Tables[2].Rows)
                        {
                            if (dRow["Name"].ToString() == "Profit And Loss Account")
                            {
                                dgvReport.Rows.Add();
                                dgvReport.Rows[AssetRow].DefaultCellStyle.Font      = newFont;
                                dgvReport.Rows[AssetRow].DefaultCellStyle.ForeColor = Color.DarkSlateGray;
                                dgvReport.Rows[AssetRow].Cells["dgvtxtAsset"].Value = dRow["Name"].ToString();
                                dgvReport.Rows[AssetRow].Cells["Amount1"].Value     = Math.Round(decTotalProfitAndLoss + decCurrentProfitLoss, PublicVariables._inNoOfDecimalPlaces).ToString("N2");
                                dgvReport.Rows[AssetRow].Cells["GroupId1"].Value    = dRow["ID"].ToString();
                                AssetRow++;
                            }
                        }
                        //-------------- Asset ---------------//
                        dgvReport.Rows.Add();
                        dgvReport.Rows[AssetRow].DefaultCellStyle.Font                = newFont;
                        dgvReport.Rows[AssetRow].Cells["dgvtxtAsset"].Value           = "Profit And Loss (Opening)";
                        dgvReport.Rows[AssetRow].Cells["Amount1"].Value               = Math.Round(decTotalProfitAndLoss, PublicVariables._inNoOfDecimalPlaces).ToString("N2");
                        dgvReport.Rows[AssetRow].Cells["Amount1"].Style.ForeColor     = Color.DarkSlateGray;
                        dgvReport.Rows[AssetRow].Cells["dgvtxtAsset"].Style.ForeColor = Color.DarkSlateGray;
                        AssetRow++;
                        //-------------- Asset ---------------//
                        dgvReport.Rows.Add();
                        dgvReport.Rows[AssetRow].DefaultCellStyle.Font                = newFont;
                        dgvReport.Rows[AssetRow].Cells["dgvtxtAsset"].Value           = "Current Period";
                        dgvReport.Rows[AssetRow].Cells["Amount1"].Value               = Math.Round(decCurrentProfitLoss, PublicVariables._inNoOfDecimalPlaces).ToString("N2");
                        dgvReport.Rows[AssetRow].Cells["Amount1"].Style.ForeColor     = Color.DarkSlateGray;
                        dgvReport.Rows[AssetRow].Cells["dgvtxtAsset"].Style.ForeColor = Color.DarkSlateGray;
                        AssetRow++;
                        TotalAssets = TotalAssets + (decCurrentProfitLoss + decTotalProfitAndLoss);
                        dgvReport.Rows.Add();
                        dgvReport.Rows[AssetRow].Cells["dgvtxtAsset"].Value = "----------------------------------------";
                        dgvReport.Rows[AssetRow].DefaultCellStyle.Font      = newFont;
                        AssetRow++;
                    }
                    else
                    {
                        dgvReport.Rows.Add();
                        dgvReport.Rows[LiabilityRow].Cells["dgvtxtLiability"].Value = "----------------------------------------";
                        dgvReport.Rows[LiabilityRow].DefaultCellStyle.Font          = newFont;
                        LiabilityRow++;
                        foreach (DataRow dRow in DsetBalanceSheet.Tables[2].Rows)
                        {
                            if (dRow["Name"].ToString() == "Profit And Loss Account")
                            {
                                dgvReport.Rows.Add();
                                dgvReport.Rows[LiabilityRow].DefaultCellStyle.Font          = newFont;
                                dgvReport.Rows[LiabilityRow].DefaultCellStyle.ForeColor     = Color.DarkSlateGray;
                                dgvReport.Rows[LiabilityRow].Cells["dgvtxtLiability"].Value = dRow[1].ToString();
                                dgvReport.Rows[LiabilityRow].Cells["Amount2"].Value         = Math.Round(decTotalProfitAndLoss + decCurrentProfitLoss, PublicVariables._inNoOfDecimalPlaces).ToString("N2");
                                dgvReport.Rows[LiabilityRow].Cells["GroupId2"].Value        = dRow[0].ToString();
                                LiabilityRow++;
                            }
                        }
                        //------------ Liability ------------//
                        dgvReport.Rows.Add();
                        dgvReport.Rows[LiabilityRow].DefaultCellStyle.Font                    = newFont;
                        dgvReport.Rows[LiabilityRow].Cells["dgvtxtLiability"].Value           = "Profit And Loss (Opening)";
                        dgvReport.Rows[LiabilityRow].Cells["Amount2"].Value                   = Math.Round(decTotalProfitAndLoss, inDecimalPlaces).ToString("N2");
                        dgvReport.Rows[LiabilityRow].Cells["Amount2"].Style.ForeColor         = Color.DarkSlateGray;
                        dgvReport.Rows[LiabilityRow].Cells["dgvtxtLiability"].Style.ForeColor = Color.DarkSlateGray;
                        TotalLiabilities += decOpeningOfProfitAndLoss;
                        LiabilityRow++;
                        //------------ Liability ------------//
                        dgvReport.Rows.Add();
                        dgvReport.Rows[LiabilityRow].DefaultCellStyle.Font                    = newFont;
                        dgvReport.Rows[LiabilityRow].Cells["dgvtxtLiability"].Value           = "Current Period";
                        dgvReport.Rows[LiabilityRow].Cells["Amount2"].Value                   = Math.Round(decCurrentProfitLoss, inDecimalPlaces).ToString("N2");
                        dgvReport.Rows[LiabilityRow].Cells["Amount2"].Style.ForeColor         = Color.DarkSlateGray;
                        dgvReport.Rows[LiabilityRow].Cells["dgvtxtLiability"].Style.ForeColor = Color.DarkSlateGray;
                        TotalLiabilities = TotalLiabilities + (decCurrentProfitLoss + decTotalProfitAndLoss); //dcProfit;
                        LiabilityRow++;
                        dgvReport.Rows.Add();
                        dgvReport.Rows[LiabilityRow].Cells["dgvtxtLiability"].Value = "----------------------------------------";
                        dgvReport.Rows[LiabilityRow].DefaultCellStyle.Font          = newFont;
                        LiabilityRow++;
                    }
                    if (AssetRow > LiabilityRow)
                    {
                        LiabilityRow = AssetRow;
                    }
                    else
                    {
                        AssetRow = LiabilityRow;
                    }
                    dgvReport.Rows.Add();
                    decimal dcDiffAsset     = 0;
                    decimal dcDiffLiability = 0;

                    LiabilityRow++;
                    AssetRow++;

                    if (TotalAssets > TotalLiabilities)
                    {
                        //--------------- Liability exceeds so in asset side ----------------//
                        dgvReport.Rows.Add();
                        dgvReport.Rows[LiabilityRow].Cells["dgvtxtLiability"].Value = "Difference";
                        dgvReport.Rows[LiabilityRow].Cells["Amount2"].Value         = Math.Round((TotalAssets - TotalLiabilities), inDecimalPlaces).ToString("N2");
                        dgvReport.Rows[LiabilityRow].DefaultCellStyle.Font          = newFont;
                        dgvReport.Rows[LiabilityRow].DefaultCellStyle.ForeColor     = Color.DarkRed;
                        dcDiffLiability = TotalAssets - TotalLiabilities;
                        LiabilityRow++;
                    }
                    else
                    {
                        //--------------- Asset exceeds so in liability side ----------------//
                        dgvReport.Rows.Add();
                        dgvReport.Rows[AssetRow].Cells["dgvtxtAsset"].Value = "Difference";
                        dgvReport.Rows[AssetRow].Cells["Amount1"].Value     = Math.Round((TotalLiabilities - TotalAssets), inDecimalPlaces).ToString("N2");
                        dgvReport.Rows[AssetRow].DefaultCellStyle.Font      = newFont;
                        dgvReport.Rows[AssetRow].DefaultCellStyle.ForeColor = Color.DarkRed;
                        dcDiffAsset = TotalLiabilities - TotalAssets;
                        AssetRow++;
                    }
                    if (AssetRow > LiabilityRow)
                    {
                        LiabilityRow = AssetRow;
                    }
                    else
                    {
                        AssetRow = LiabilityRow;
                    }
                    dgvReport.Rows.Add();
                    dgvReport.Rows.Add();
                    AssetRow++;
                    dgvReport.Rows[AssetRow].Cells["Amount1"].Value = "________________________";
                    dgvReport.Rows[AssetRow].Cells["Amount2"].Value = "________________________";
                    dgvReport.Rows.Add();
                    AssetRow++;
                    dgvReport.Rows[AssetRow].DefaultCellStyle.Font          = newFont;
                    dgvReport.Rows[AssetRow].Cells["dgvtxtLiability"].Value = "Total";
                    dgvReport.Rows[AssetRow].Cells["dgvtxtAsset"].Value     = "Total";
                    dgvReport.Rows[AssetRow].Cells["Amount1"].Value         = Math.Round((TotalAssets + dcDiffAsset), inDecimalPlaces).ToString("N2");
                    dgvReport.Rows[AssetRow].Cells["Amount2"].Value         = Math.Round((TotalLiabilities + dcDiffLiability), inDecimalPlaces).ToString("N2");
                    LiabilityRow++;
                    if (dgvReport.Columns.Count > 0)
                    {
                        dgvReport.Columns["Amount1"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                        dgvReport.Columns["Amount2"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                    }
                    decPrintOrNot  = TotalAssets + dcDiffAsset;
                    decPrintOrNot1 = TotalLiabilities + dcDiffLiability;
                    if (inCurrenRowIndex >= 0 && dgvReport.Rows.Count > 0 && inCurrenRowIndex < dgvReport.Rows.Count)
                    {
                        if (dgvReport.Rows[inCurrenRowIndex].Cells[inCurentcolIndex].Visible)
                        {
                            dgvReport.CurrentCell = dgvReport.Rows[inCurrenRowIndex].Cells[inCurentcolIndex];
                        }
                        if (dgvReport.CurrentCell != null && dgvReport.CurrentCell.Visible)
                        {
                            dgvReport.CurrentCell.Selected = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                formMDI.infoError.ErrorString = "BS1:" + ex.Message;
            }
        }
Exemple #19
0
 /// <summary>
 /// The form will reset here, clearing the controlls
 /// </summary>
 public void ClearFunction()
 {
     try
     {
         VoucherNumberGeneration();
         decPDCpayableEditId = 0;
         CurrencySP SpCurrency = new CurrencySP();
         CurrencyInfo InfoCurrency = new CurrencyInfo();
         btnAgainstRef.Enabled = false;
         btnDelete.Enabled = false;
         isInEditMode = false;
         PrintCheck();
         cmbAccountNameFill();
         cmbBankAccountFill();
         txtAmount.Clear();
         txtcheckNo.Clear();
         FinancialYearDate();
         txtVoucherDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         txtChequeDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         txtNarration.Clear();
         dtblPartyBalance.Clear();
         btnSave.Text = "Save";
         cmbAccountLedger.Focus();
         if (PDCPayableRegisterObj != null)
         {
             PDCPayableRegisterObj.Close();
         }
         if (PDCpayableReportObj != null)
         {
             PDCpayableReportObj.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PP6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void FillGrid()
 {
     try
     {
         if (!isFormLoad)
         {
             DateValidation objValidation = new DateValidation();
             objValidation.DateValidationFunction(txtToDate);
             if (txtToDate.Text == string.Empty)
                 txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
             Font newFont = new Font(dgvReport.Font, FontStyle.Bold);
             CurrencyInfo InfoCurrency = new CurrencyInfo();
             CurrencySP SpCurrency = new CurrencySP();
             InfoCurrency = SpCurrency.CurrencyView(1);
             int inDecimalPlaces = InfoCurrency.NoOfDecimalPlaces;
             dgvReport.Rows.Clear();
             FinancialStatementSP SpFinance = new FinancialStatementSP();
             DataSet DsetBalanceSheet = new DataSet();
             DataTable dtbl = new DataTable();
             SettingsInfo InfoSettings = new SettingsInfo();
             SettingsSP SpSettings = new SettingsSP();
             //--------------- Selection Of Calculation Method According To Settings ------------------// 
             if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "FIFO")
             {
                 calculationMethod = "FIFO";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Average Cost")
             {
                 calculationMethod = "Average Cost";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "High Cost")
             {
                 calculationMethod = "High Cost";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Low Cost")
             {
                 calculationMethod = "Low Cost";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Last Purchase Rate")
             {
                 calculationMethod = "Last Purchase Rate";
             }
             DsetBalanceSheet = SpFinance.BalanceSheet(PublicVariables._dtFromDate, DateTime.Parse(txtToDate.Text));
             //------------------- Asset -------------------------------// 
             dtbl = DsetBalanceSheet.Tables[0];
             foreach (DataRow rw in dtbl.Rows)
             {
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = rw["Name"].ToString();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value = rw["Balance"].ToString();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["GroupId1"].Value = rw["ID"].ToString();
             }
             decimal dcTotalAsset = 0;
             if (dtbl.Rows.Count > 0)
             {
                 dcTotalAsset = decimal.Parse(dtbl.Compute("Sum(Balance)", string.Empty).ToString());
             }
             //------------------------ Liability ---------------------//
             dtbl = new DataTable();
             dtbl = DsetBalanceSheet.Tables[1];
             int index = 0;
             foreach (DataRow rw in dtbl.Rows)
             {
                 if (index < dgvReport.Rows.Count)
                 {
                     dgvReport.Rows[index].Cells["dgvtxtLiability"].Value = rw["Name"].ToString();
                     dgvReport.Rows[index].Cells["Amount2"].Value = rw["Balance"].ToString();
                     dgvReport.Rows[index].Cells["GroupId2"].Value = rw["ID"].ToString();
                 }
                 else
                 {
                     dgvReport.Rows.Add();
                     dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = rw["Name"].ToString();
                     dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value = rw["Balance"].ToString();
                     dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["GroupId2"].Value = rw["ID"].ToString();
                 }
                 index++;
             }
             decimal dcTotalLiability = 0;
             if (dtbl.Rows.Count > 0)
             {
                 dcTotalLiability = decimal.Parse(dtbl.Compute("Sum(Balance)", string.Empty).ToString());
             }
             decimal dcClosingStock = SpFinance.StockValueGetOnDate(Convert.ToDateTime(txtToDate.Text), calculationMethod, false, false);
             dcClosingStock = Math.Round(dcClosingStock, inDecimalPlaces);
             //---------------------Opening Stock---------------------------------------------------------------------------------------------------------------
             decimal dcOpeninggStock = SpFinance.StockValueGetOnDate(PublicVariables._dtFromDate, calculationMethod, true, true);
             decimal dcProfit = 0;
             DataSet dsetProfitAndLoss = new DataSet();
             dsetProfitAndLoss = SpFinance.ProfitAndLossAnalysisUpToaDateForBalansheet(PublicVariables._dtFromDate, DateTime.Parse(txtToDate.Text));
             DataTable dtblProfit = new DataTable();
             dtblProfit = dsetProfitAndLoss.Tables[0];
             for (int i = 0; i < dsetProfitAndLoss.Tables.Count; ++i)
             {
                 dtbl = dsetProfitAndLoss.Tables[i];
                 decimal dcSum = 0;
                 if (i == 0 || (i % 2) == 0)
                 {
                     if (dtbl.Rows.Count > 0)
                     {
                         dcSum = decimal.Parse(dtbl.Compute("Sum(Debit)", string.Empty).ToString());
                         dcProfit = dcProfit - dcSum;
                     }
                 }
                 else
                 {
                     if (dtbl.Rows.Count > 0)
                     {
                         dcSum = decimal.Parse(dtbl.Compute("Sum(Credit)", string.Empty).ToString());
                         dcProfit = dcProfit + dcSum;
                     }
                 }
             }
             decimal decCurrentProfitLoss = 0;
             decCurrentProfitLoss = dcProfit + (dcClosingStock - dcOpeninggStock);
             decimal dcProfitOpening = 0;
             DataSet dsetProfitAndLossOpening = new DataSet();
             dsetProfitAndLossOpening = SpFinance.ProfitAndLossAnalysisUpToaDateForPreviousYears(PublicVariables._dtFromDate);
             DataTable dtblProfitOpening = new DataTable();
             dtblProfitOpening = dsetProfitAndLossOpening.Tables[0];
             for (int i = 0; i < dsetProfitAndLossOpening.Tables.Count; ++i)
             {
                 dtbl = dsetProfitAndLossOpening.Tables[i];
                 decimal dcSum = 0;
                 if (i == 0 || (i % 2) == 0)
                 {
                     if (dtbl.Rows.Count > 0)
                     {
                         dcSum = decimal.Parse(dtbl.Compute("Sum(Debit)", string.Empty).ToString());
                         dcProfitOpening = dcProfitOpening - dcSum;
                     }
                 }
                 else
                 {
                     if (dtbl.Rows.Count > 0)
                     {
                         dcSum = decimal.Parse(dtbl.Compute("Sum(Credit)", string.Empty).ToString());
                         dcProfitOpening = dcProfitOpening + dcSum;
                     }
                 }
             }
             DataTable dtblProfitLedgerOpening = new DataTable();
             dtblProfitLedgerOpening = DsetBalanceSheet.Tables[3];
             decimal decProfitLedgerOpening = 0;
             foreach (DataRow dRow in dtblProfitLedgerOpening.Rows)
             {
                 decProfitLedgerOpening += decimal.Parse(dRow["Balance"].ToString());
             }
             DataTable dtblProf = new DataTable();
             dtblProf = DsetBalanceSheet.Tables[2];
             decimal decProfitLedger = 0;
             if (dtblProf.Rows.Count > 0)
             {
                 decProfitLedger = decimal.Parse(dtblProf.Compute("Sum(Balance)", string.Empty).ToString());
             }
             decimal decTotalProfitAndLoss = 0;
             if (dcProfitOpening >= 0)
             {
                 decTotalProfitAndLoss = decProfitLedger;
             }
             else if (dcProfitOpening < 0)
             {
                 decTotalProfitAndLoss = decProfitLedger;
             }
             index = 0;
             if (dcClosingStock >= 0)
             {
                 //---------- Asset ----------//
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = "Closing Stock";
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value = Math.Round(dcClosingStock, inDecimalPlaces);
                 dcTotalAsset += dcClosingStock;
             }
             else
             {
                 //--------- Liability ---------//
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = "Closing Stock";
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value = -(Math.Round(dcClosingStock, inDecimalPlaces));
                 dcTotalLiability += -dcClosingStock;
             }
             dgvReport.Rows.Add();
             decimal decOpeningOfProfitAndLoss = decProfitLedgerOpening + dcProfitOpening;
             decimal decTotalProfitAndLossOverAll = decTotalProfitAndLoss + decOpeningOfProfitAndLoss + decCurrentProfitLoss;
             if (decTotalProfitAndLossOverAll <= 0)
             {
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = "----------------------------------------";
                 dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont;
                 foreach (DataRow dRow in dtblProf.Rows)
                 {
                     if (dRow["Name"].ToString() == "Profit And Loss Account")
                     {
                         dgvReport.Rows.Add();
                         dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont;
                         dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.DarkSlateGray;
                         dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = dRow["Name"].ToString();
                         if (decCurrentProfitLoss < 0)
                         {
                             decCurrentProfitLoss = decCurrentProfitLoss * -1;
                         }
                         dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value =Math.Round(decTotalProfitAndLoss + decCurrentProfitLoss,PublicVariables._inNoOfDecimalPlaces);
                         dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["GroupId1"].Value = dRow["ID"].ToString();
                     }
                 }
                 //-------------- Asset ---------------//
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont;
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = "Profit And Loss (Opening)";
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value = Math.Round(decTotalProfitAndLoss, PublicVariables._inNoOfDecimalPlaces);
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Style.ForeColor = Color.DarkSlateGray;
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Style.ForeColor = Color.DarkSlateGray;
                 //-------------- Asset ---------------//
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont;
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = "Current Period";
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value = Math.Round(decCurrentProfitLoss, PublicVariables._inNoOfDecimalPlaces);
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Style.ForeColor = Color.DarkSlateGray;
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Style.ForeColor = Color.DarkSlateGray;
                 dcTotalAsset = dcTotalAsset + (decCurrentProfitLoss + decTotalProfitAndLoss);
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = "----------------------------------------";
                 dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont;
             }
             else if (decTotalProfitAndLossOverAll > 0)
             {
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = "----------------------------------------";
                 dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont;
                 foreach (DataRow dRow in dtblProf.Rows)
                 {
                     if (dRow["Name"].ToString() == "Profit And Loss Account")
                     {
                         dgvReport.Rows.Add();
                         dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont;
                         dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.DarkSlateGray;
                         dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = dRow[1].ToString();
                         dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value =Math.Round(decTotalProfitAndLoss + decCurrentProfitLoss,PublicVariables._inNoOfDecimalPlaces);
                         dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["GroupId2"].Value = dRow[0].ToString();
                     }
                 }
                 //------------ Liability ------------//
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont;
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = "Profit And Loss (Opening)";
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value = Math.Round(decTotalProfitAndLoss, inDecimalPlaces);
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Style.ForeColor = Color.DarkSlateGray;
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Style.ForeColor = Color.DarkSlateGray;
                 dcTotalLiability += decOpeningOfProfitAndLoss;
                 //------------ Liability ------------//
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont;
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = "Current Period";
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value = Math.Round(decCurrentProfitLoss, inDecimalPlaces);
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Style.ForeColor = Color.DarkSlateGray;
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Style.ForeColor = Color.DarkSlateGray;
                 dcTotalLiability = dcTotalLiability + (decCurrentProfitLoss + decTotalProfitAndLoss); //dcProfit;
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = "----------------------------------------";
                 dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont;
             }
             dgvReport.Rows.Add();
             decimal dcDiffAsset = 0;
             decimal dcDiffLiability = 0;
             decimal dcTotalValue = dcTotalAsset;
             if (dcTotalAsset != dcTotalLiability)
             {
                 if (dcTotalAsset > dcTotalLiability)
                 {
                     //--------------- Liability exceeds so in asset side ----------------//
                     dgvReport.Rows.Add();
                     dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = "Difference";
                     dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value = Math.Round((dcTotalAsset - dcTotalLiability), inDecimalPlaces);
                     dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont;
                     dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.DarkRed;
                     dcDiffLiability = dcTotalAsset - dcTotalLiability;
                 }
                 else
                 {
                     //--------------- Asset exceeds so in liability side ----------------//
                     dgvReport.Rows.Add();
                     dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = "Difference";
                     dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value = Math.Round((dcTotalLiability - dcTotalAsset), inDecimalPlaces); ;
                     dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont;
                     dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.DarkRed;
                     dcDiffAsset = dcTotalLiability - dcTotalAsset;
                 }
             }
             dgvReport.Rows.Add();
             dgvReport.Rows.Add();
             dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value = "__________________________";
             dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value = "__________________________";
             dgvReport.Rows.Add();
             dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font = newFont;
             dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = "Total";
             dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = "Total";
             dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value = Math.Round((dcTotalAsset + dcDiffAsset), inDecimalPlaces);
             dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value = Math.Round((dcTotalLiability + dcDiffLiability), inDecimalPlaces);
             if (dgvReport.Columns.Count > 0)
             {
                 dgvReport.Columns["Amount1"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                 dgvReport.Columns["Amount2"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
             }
             decPrintOrNot = dcTotalAsset + dcDiffAsset;
             decPrintOrNot1 = dcTotalLiability + dcDiffLiability;
             if (inCurrenRowIndex >= 0 && dgvReport.Rows.Count > 0 && inCurrenRowIndex < dgvReport.Rows.Count)
             {
                 if (dgvReport.Rows[inCurrenRowIndex].Cells[inCurentcolIndex].Visible)
                 {
                     dgvReport.CurrentCell = dgvReport.Rows[inCurrenRowIndex].Cells[inCurentcolIndex];
                 }
                 if (dgvReport.CurrentCell != null && dgvReport.CurrentCell.Visible)
                     dgvReport.CurrentCell.Selected = true;
             }
             inCurrenRowIndex = 0;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("BS :1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #21
0
 /// <summary>
 /// Function to Total Amount Calculation
 /// </summary>
 public void TotalAmountCalculation()
 {
     try
     {
         decimal DecTotalAmount = 0;
         foreach (DataGridViewRow dr in dgvSalesOrder.Rows)
         {
             if (dr.Cells["dgvtxtProductId"].Value != null && dr.Cells["dgvtxtProductId"].Value.ToString() != string.Empty)
             {
                 if (dr.Cells["dgvtxtAmount"].Value != null && dr.Cells["dgvtxtAmount"].Value.ToString() != string.Empty)
                 {
                     CurrencySP currencysp = new CurrencySP();
                     decimal decAmt = Convert.ToDecimal(dr.Cells["dgvtxtAmount"].Value);
                     DecTotalAmount = DecTotalAmount + decAmt;
                     DecTotalAmount = Math.Round(DecTotalAmount, PublicVariables._inNoOfDecimalPlaces);
                     txtTotalAmount.Text = Convert.ToString(DecTotalAmount);
                     // lblCurrencysymbol.Text = new CurrencySP().GetCurrencySymbolByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()));
                 }
             }
             else if (dgvSalesOrder.Rows.Count == 1 && dr.Cells["dgvtxtAmount"].Value == null)
             {
                 txtTotalAmount.Text = "0.00";
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SO27:" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #22
0
 /// <summary>
 /// Function to delete
 /// </summary>
 public void DeleteFunction()
 {
     try
     {
         CurrencySP spCurrency = new CurrencySP();
         if (spCurrency.CurrencyCheckReferences(decId) == -1)
         {
             Messages.ReferenceExistsMessage();
         }
         else
         {
             Messages.DeletedMessage();
             Clear();
             GridFill();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("C8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill Datagridview after calculation
 /// </summary>
 public void GridFill()
 {
     try
     {
         if (!isFormLoad)
         {
             string calculationMethod = string.Empty;
             SettingsInfo InfoSettings = new SettingsInfo();
             SettingsSP SpSettings = new SettingsSP();
             //--------------- Selection Of Calculation Method According To Settings ------------------// 
             if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "FIFO")
             {
                 calculationMethod = "FIFO";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Average Cost")
             {
                 calculationMethod = "Average Cost";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "High Cost")
             {
                 calculationMethod = "High Cost";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Low Cost")
             {
                 calculationMethod = "Low Cost";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Last Purchase Rate")
             {
                 calculationMethod = "Last Purchase Rate";
             }
             FinancialStatementSP SpFinance1 = new FinancialStatementSP();
             DataTable dtbl1 = new DataTable();
             CurrencyInfo InfoCurrency = new CurrencyInfo();
             CurrencySP SpCurrency = new CurrencySP();
             int inDecimalPlaces = InfoCurrency.NoOfDecimalPlaces;
             decimal dcClosingStock = SpFinance1.StockValueGetOnDate(Convert.ToDateTime(txtTodate.Text), calculationMethod, false, false);
             dcClosingStock = Math.Round(dcClosingStock, inDecimalPlaces);
             //---------------------Opening Stock-----------------------
             decimal dcOpeninggStock = SpFinance1.StockValueGetOnDate(PublicVariables._dtFromDate, calculationMethod, true, true);
             decimal dcProfit = 0;
             DataSet dsetProfitAndLoss = new DataSet();
             dsetProfitAndLoss = SpFinance1.ProfitAndLossAnalysisUpToaDateForBalansheet(PublicVariables._dtFromDate, DateTime.Parse(txtTodate.Text));
             DataTable dtblProfit = new DataTable();
             dtblProfit = dsetProfitAndLoss.Tables[0];
             for (int i = 0; i < dsetProfitAndLoss.Tables.Count; ++i)
             {
                 dtbl1 = dsetProfitAndLoss.Tables[i];
                 decimal dcSum = 0;
                 if (i == 0 || (i % 2) == 0)
                 {
                     if (dtbl1.Rows.Count > 0)
                     {
                         dcSum = decimal.Parse(dtbl1.Compute("Sum(Debit)", string.Empty).ToString());
                     }
                 }
                 else
                 {
                     if (dtbl1.Rows.Count > 0)
                     {
                         dcSum = decimal.Parse(dtbl1.Compute("Sum(Credit)", string.Empty).ToString());
                     }
                 }
             }
             DateValidation objValidation = new DateValidation();
             objValidation.DateValidationFunction(txtTodate);
             if (txtTodate.Text == string.Empty)
                 txtTodate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
             Font newFont = new Font(dgvTrailBalance.Font, FontStyle.Bold);
             FinancialStatementSP SpFinance = new FinancialStatementSP();
             DataSet DsetTrailbalance = new DataSet();
             DataTable dtbl = new DataTable();
             decimal dcTotalCredit = 0;
             decimal dcTotalDebit = 0;
             DateValidation objvalidation = new DateValidation();
             objvalidation.DateValidationFunction(txtFromDate);
             if (txtFromDate.Text == string.Empty)
             {
                 txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy");
             }
             objvalidation.DateValidationFunction(txtTodate);
             if (txtTodate.Text == string.Empty)
             {
                 txtTodate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
             }
             DataTable dtblTrail = new DataTable();
             DataTable dtblTrail1 = new DataTable();
             DataTable dtblProfitAndLossAcc = new DataTable();
             DataTable dtblProfitAndLossAcc1 = new DataTable();
             DataSet dsTrial = new DataSet();
             Font newfont = new Font(dgvTrailBalance.Font, FontStyle.Bold);
             FinancialStatementSP spfinancial = new FinancialStatementSP();
             dgvTrailBalance.Rows.Clear();
             dsTrial = spfinancial.TrialBalance(DateTime.Parse(txtFromDate.Text), DateTime.Parse(txtTodate.Text), 0);
             dtblTrail = dsTrial.Tables[0];
             dtblProfitAndLossAcc = dsTrial.Tables[1];
             if (dgvTrailBalance.RowCount > 0)
             {
                 dcTotalCredit = decimal.Parse(dtblTrail.Compute("Sum(credit)", string.Empty).ToString());
                 dcTotalDebit = decimal.Parse(dtblTrail.Compute("Sum(debit)", string.Empty).ToString());
             }
             for (int i = 0; i < dtblTrail.Rows.Count; ++i)
             {
                 dgvTrailBalance.Rows.Add();
                 if (Convert.ToDecimal(dtblTrail.Rows[i]["accountGroupId"].ToString()) != 6)
                 {
                     dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtAccountGroupId"].Value = dtblTrail.Rows[i]["accountGroupId"];
                     dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["accountGroupName"].Value = dtblTrail.Rows[i]["name"];
                     dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["openingBalance"].Value = dtblTrail.Rows[i]["OpeningBalance"];
                     dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtBalance"].Value = dtblTrail.Rows[i]["Balance"];
                     dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["credit"].Value = dtblTrail.Rows[i]["credit"];
                     dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["debit"].Value = dtblTrail.Rows[i]["debit"];
                     dcTotalCredit += decimal.Parse(dtblTrail.Rows[i]["credit"].ToString());
                     dcTotalDebit += decimal.Parse(dtblTrail.Rows[i]["debit"].ToString());
                 }
                 else
                 {
                     decimal decOpBalance = dcOpeninggStock + Convert.ToDecimal(dtblTrail.Rows[i]["OpBalance"].ToString());
                     decimal decBalance = dcOpeninggStock + Convert.ToDecimal(dtblTrail.Rows[i]["Balance1"].ToString());
                     string strOpBalance = string.Empty;
                     string strBalance = string.Empty;
                     if (decOpBalance < 0)
                     {
                         strOpBalance = Math.Round(decOpBalance, PublicVariables._inNoOfDecimalPlaces).ToString() + "Cr";
                     }
                     else
                     {
                         strOpBalance = Math.Round(decOpBalance, PublicVariables._inNoOfDecimalPlaces).ToString() + "Dr";
                     }
                     if (decBalance < 0)
                     {
                         strBalance = Math.Round(decBalance, PublicVariables._inNoOfDecimalPlaces).ToString() + "Cr";
                     }
                     else
                     {
                         strBalance = Math.Round(decBalance, PublicVariables._inNoOfDecimalPlaces).ToString() + "Dr";
                     }
                     dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtAccountGroupId"].Value = dtblTrail.Rows[i]["accountGroupId"];
                     dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["accountGroupName"].Value = dtblTrail.Rows[i]["name"];
                     dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["openingBalance"].Value = strOpBalance;
                     dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtBalance"].Value = strBalance;
                     dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["credit"].Value = dtblTrail.Rows[i]["credit"];
                     dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["debit"].Value = dtblTrail.Rows[i]["debit"];
                     dcTotalCredit += decimal.Parse(dtblTrail.Rows[i]["credit"].ToString());
                     dcTotalDebit += decimal.Parse(dtblTrail.Rows[i]["debit"].ToString());
                 }
             }
             decimal OpeningProfit;
             dtblProfitAndLossAcc1 = dsTrial.Tables[2];
             if (dgvTrailBalance.RowCount > 0)
             {
                 decimal dcTotalCredit1 = decimal.Parse(dtblTrail.Compute("Sum(credit)", string.Empty).ToString());
                 decimal dcTotalDebit1 = decimal.Parse(dtblTrail.Compute("Sum(debit)", string.Empty).ToString());
                 OpeningProfit = dcTotalCredit1 + dcTotalDebit1;
             }
             DataSet DsetBalanceSheet = new DataSet();
             DsetBalanceSheet = SpFinance.BalanceSheet(PublicVariables._dtFromDate, DateTime.Parse(txtTodate.Text));
             DataTable dtblProf = new DataTable();
             decimal dcProfitOpening = 0;
             dtblProf = DsetBalanceSheet.Tables[2];
             decimal decProfitLedger = 0;
             if (dtblProf.Rows.Count > 0)
             {
                 decProfitLedger = decimal.Parse(dtblProf.Compute("Sum(Balance)", string.Empty).ToString());
             }
             DataTable dtblProfitLedgerOpening = new DataTable();
             dtblProfitLedgerOpening = DsetBalanceSheet.Tables[3];
             decimal decProfitLedgerOpening = 0;
             foreach (DataRow dRow in dtblProfitLedgerOpening.Rows)
             {
                 decProfitLedgerOpening += decimal.Parse(dRow["Balance"].ToString());
             }
             decimal decTotalProfitAndLoss = decProfitLedger;
             decimal OpeningProfit1;
             decimal openingBalance;
             dgvTrailBalance.Rows.Add();
             dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtSlNo"].Value = "  ";
             dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["accountGroupName"].Value = "Profit and Loss";
             dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtAccountGroupId"].Value = "0";
             openingBalance = Convert.ToDecimal(dtblProfitAndLossAcc.Rows[0]["OpeningBalance"].ToString());
             {
                 if (openingBalance > 0)
                 {
                     dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["openingBalance"].Value = openingBalance + "Dr";
                 }
                 else
                     dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["openingBalance"].Value = (-1) * openingBalance + "Cr";
             }
             dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtSlNo"].Value = dgvTrailBalance.Rows.Count.ToString();
             dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.Blue;
             dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].DefaultCellStyle.Font = new Font(dgvTrailBalance.Font, FontStyle.Regular);
             dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["credit"].Value = dtblProfitAndLossAcc.Rows[0]["credit"].ToString();
             dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["debit"].Value = dtblProfitAndLossAcc.Rows[0]["debit"].ToString();
             OpeningProfit1 = (Convert.ToDecimal(dtblProfitAndLossAcc.Rows[0]["OpeningBalance"].ToString())) + Convert.ToDecimal(dtblProfitAndLossAcc.Rows[0]["debit"].ToString()) - Convert.ToDecimal(dtblProfitAndLossAcc.Rows[0]["credit"].ToString());
             {
                 if (OpeningProfit1 > 0)
                 {
                     dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtBalance"].Value = decTotalProfitAndLoss + dcProfit + "Dr";
                 }
                 else
                     dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtBalance"].Value = (-1) * decTotalProfitAndLoss - dcProfit + "Cr";
             };
             dcTotalCredit = dcTotalCredit + Convert.ToDecimal(dtblProfitAndLossAcc.Rows[0]["credit"].ToString());
             dcTotalDebit = dcTotalDebit + Convert.ToDecimal(dtblProfitAndLossAcc.Rows[0]["debit"].ToString());
             //=================================Net profit and NetLoss transation for previousyear==============
             decimal decprofitLossbal = 0;
             decimal decbalance = 0;
             decimal decProfitAndLossOfPrevious = decProfitLedgerOpening;
             dgvTrailBalance.Rows.Add();
             if (dcProfitOpening > 0)
             {
                 dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["openingBalance"].Value = dcProfitOpening + "Dr";
                 decprofitLossbal = dcProfitOpening;
             }
             if (dcProfitOpening <= 0)
             {
                 dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["openingBalance"].Value = (-1) * dcProfitOpening + "Cr";
                 decprofitLossbal = dcProfitOpening;
             }
             dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtSlNo"].Value = "  ";
             dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["accountGroupName"].Value = "Profit and Loss Opening";
             dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["openingBalance"].Value = "0.00Dr";
             dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.Brown;
             dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].DefaultCellStyle.Font = new Font(dgvTrailBalance.Font, FontStyle.Regular);
             dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtAccountGroupId"].Value = "0";
             if (decProfitAndLossOfPrevious > 0)
             {
                 dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["debit"].Value = decProfitAndLossOfPrevious;
                 dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["credit"].Value = "0.00";
                 decbalance = (decProfitAndLossOfPrevious);
             }
             if (decProfitAndLossOfPrevious <= 0)
             {
                 dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["credit"].Value = (-1) * (decProfitAndLossOfPrevious);
                 dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["debit"].Value = "0.00";
                 decbalance = ((decProfitAndLossOfPrevious));
             }
             if (decbalance >= 0)
             {
                 dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtBalance"].Value = decbalance + decprofitLossbal + "Dr";
             }
             if (decbalance < 0)
             {
                 decbalance = -(decbalance);
                 dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtBalance"].Value = decbalance + decprofitLossbal + "Cr";
             }
             dgvTrailBalance.Rows.Add();
             dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtSlNo"].Value = "  ";
             dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["accountGroupName"].Value = "Total:";
             dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtSlNo"].Value = string.Empty;
             dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.Red;
             dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].DefaultCellStyle.Font = new Font(dgvTrailBalance.Font, FontStyle.Bold);
             dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["credit"].Value = dcTotalCredit;
             dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["debit"].Value = dcTotalDebit;
             if (dgvTrailBalance.Columns.Count > 0)
             {
                 dgvTrailBalance.Columns["credit"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                 dgvTrailBalance.Columns["debit"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                 dgvTrailBalance.Columns["openingBalance"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                 dgvTrailBalance.Columns["dgvtxtBalance"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
             }
             dgvTrailBalance.ScrollBars = ScrollBars.Both;
             dgvTrailBalance.ClearSelection();
             if (inCurrenRowIndex > 0 && dgvTrailBalance.Rows.Count > 0 && inCurrenRowIndex < dgvTrailBalance.Rows.Count)
             {
                 if (dgvTrailBalance.Rows[inCurrenRowIndex].Cells[inCurrentColIndex].Visible)
                 {
                     dgvTrailBalance.CurrentCell = dgvTrailBalance.Rows[inCurrenRowIndex].Cells[inCurrentColIndex];
                 }
                 else
                 {
                     dgvTrailBalance.CurrentCell = dgvTrailBalance.Rows[inCurrenRowIndex].Cells["debit"];
                 }
                 dgvTrailBalance.CurrentCell.Selected = true;
             }
             inCurrenRowIndex = 0;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Tb:2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #24
0
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void Gridfill()
 {
     try
     {
         if (!isFormLoad)
         {
             DateValidation objValidation = new DateValidation();
             objValidation.DateValidationFunction(txtFromDate);
             if (txtFromDate.Text == string.Empty)
             {
                 txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy");
             }
             objValidation.DateValidationFunction(txtToDate);
             if (txtToDate.Text == string.Empty)
             {
                 txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
             }
             Font         newFont      = new Font(dgvProfitAndLoss.Font, FontStyle.Bold);
             CurrencyInfo InfoCurrency = new CurrencyInfo();
             CurrencySP   SpCurrency   = new CurrencySP();
             InfoCurrency = SpCurrency.CurrencyView(1);
             int inDecimalPlaces = InfoCurrency.NoOfDecimalPlaces;
             dgvProfitAndLoss.Rows.Clear();
             FinancialStatementSP spFinancial   = new FinancialStatementSP();
             DataTable            dtblFinancial = new DataTable();
             DataSet      DsetProfitAndLoss     = new DataSet();
             SettingsInfo infoSettings          = new SettingsInfo();
             SettingsSP   SpSettings            = new SettingsSP();
             //---------check  calculation method
             if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "FIFO")
             {
                 calculationMethod = "FIFO";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Average Cost")
             {
                 calculationMethod = "Average Cost";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "High Cost")
             {
                 calculationMethod = "High Cost";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Low Cost")
             {
                 calculationMethod = "Low Cost";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Last Purchase Rate")
             {
                 calculationMethod = "Last Purchase Rate";
             }
             DsetProfitAndLoss = spFinancial.ProfitAndLossAnalysis(DateTime.Parse(txtFromDate.Text), DateTime.Parse(txtToDate.Text));
             //---- Opening Stock
             dgvProfitAndLoss.Rows.Add();
             decimal dcOpeningStock = spFinancial.StockValueGetOnDate(DateTime.Parse(txtFromDate.Text), DateTime.Parse(txtToDate.Text), calculationMethod, true, false);
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Opening Stock";
             if (dcOpeningStock > 0)
             {
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = Math.Round(dcOpeningStock, inDecimalPlaces);
             }
             else
             {
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = -(Math.Round(dcOpeningStock, inDecimalPlaces));
             }
             //Closing Stock
             decimal dcClosingStock = 0;
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Closing Stock";
             dcClosingStock = spFinancial.StockValueGetOnDate(DateTime.Parse(txtToDate.Text), calculationMethod, false, false);
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = Math.Round(dcClosingStock, inDecimalPlaces);
             /// ---Purchase Account  - Debit
             dtblFinancial = new DataTable();
             dtblFinancial = DsetProfitAndLoss.Tables[0];
             dgvProfitAndLoss.Rows.Add();
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Purchase Accounts";
             decimal dcPurchaseAccount = 0m;
             if (dtblFinancial.Rows.Count > 0)
             {
                 foreach (DataRow rw in dtblFinancial.Rows)
                 {
                     decimal dcBalance = decimal.Parse(rw["Debit"].ToString().ToString());
                     dcPurchaseAccount += dcBalance;
                 }
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId1"].Value = "11";
             }
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcPurchaseAccount.ToString();
             //---Sales Account  -Credit
             dtblFinancial = new DataTable();
             dtblFinancial = DsetProfitAndLoss.Tables[1];
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Sales Accounts";
             decimal dcSalesAccount = 0m;
             if (dtblFinancial.Rows.Count > 0)
             {
                 foreach (DataRow rw in dtblFinancial.Rows)
                 {
                     decimal dcBalance = decimal.Parse(rw["Credit"].ToString().ToString());
                     dcSalesAccount += dcBalance;
                 }
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId2"].Value = "10";
             }
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcSalesAccount.ToString();
             dgvProfitAndLoss.Rows.Add();
             dgvProfitAndLoss.Rows.Add();
             //---Direct Expense
             dtblFinancial = new DataTable();
             dtblFinancial = DsetProfitAndLoss.Tables[2];
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Direct Expenses";
             decimal dcDirectExpense = 0m;
             if (dtblFinancial.Rows.Count > 0)
             {
                 foreach (DataRow rw in dtblFinancial.Rows)
                 {
                     decimal dcBalance = Convert.ToDecimal(rw["Debit"].ToString());
                     dcDirectExpense += dcBalance;
                 }
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId1"].Value = "13";
             }
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcDirectExpense.ToString();
             //----Direct Income
             dtblFinancial = new DataTable();
             dtblFinancial = DsetProfitAndLoss.Tables[3];
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Direct Incomes";
             decimal dcDirectIncoome = 0m;
             if (dtblFinancial.Rows.Count > 0)
             {
                 foreach (DataRow rw in dtblFinancial.Rows)
                 {
                     decimal dcBalance = Convert.ToDecimal(rw["Credit"].ToString());
                     dcDirectIncoome += dcBalance;
                 }
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId2"].Value = "12";
             }
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcDirectIncoome.ToString();
             dgvProfitAndLoss.Rows.Add();
             dgvProfitAndLoss.Rows.Add();
             dgvProfitAndLoss.Rows.Add();
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = "_______________________";
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = "_______________________";
             dgvProfitAndLoss.Rows.Add();
             decimal dcTotalExpense = 0;
             decimal dcTotalIncome  = 0;
             dcTotalExpense = dcOpeningStock + dcPurchaseAccount + dcDirectExpense;
             dcTotalIncome  = dcClosingStock + dcSalesAccount + dcDirectIncoome;
             dcTotalExpense = Math.Round(dcTotalExpense, inDecimalPlaces);
             dcTotalIncome  = Math.Round(dcTotalIncome, inDecimalPlaces);
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].DefaultCellStyle.Font         = newFont;
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Total";
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value   = "Total";
             decimal dcGrossProfit = 0;
             decimal dcGrossLoss   = 0;
             if (dcTotalExpense > dcTotalIncome)
             {
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value           = dcTotalExpense.ToString();
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value           = dcTotalExpense.ToString();
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtIncome"].Value            = "Gross Loss b/d ";
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount2"].Value           = dcTotalExpense - dcTotalIncome;
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount2"].Style.ForeColor = Color.Red;
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtIncome"].Style.ForeColor  = Color.Red;
                 dgvProfitAndLoss.Rows.Add();
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Gross Loss b/d ";
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value  = dcTotalExpense - dcTotalIncome;
                 dcGrossLoss = dcTotalExpense - dcTotalIncome;
             }
             else
             {
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value            = dcTotalIncome.ToString();
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value            = dcTotalIncome.ToString();
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtExpenses"].Value           = "Gross Profit c/d ";
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount1"].Value            = dcTotalIncome - dcTotalExpense;
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount1"].Style.ForeColor  = Color.Green;
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtExpenses"].Style.ForeColor = Color.Green;
                 dgvProfitAndLoss.Rows.Add();
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value  = "Gross Profit c/d ";
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcTotalIncome - dcTotalExpense;
                 dcGrossProfit = dcTotalIncome - dcTotalExpense;
             }
             dgvProfitAndLoss.Rows.Add();
             ///------Indirect Expense
             dtblFinancial = new DataTable();
             dtblFinancial = DsetProfitAndLoss.Tables[4];
             dgvProfitAndLoss.Rows.Add();
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Indirect Expenses";
             decimal dcIndirectExpense = 0;
             if (dtblFinancial.Rows.Count > 0)
             {
                 foreach (DataRow rw in dtblFinancial.Rows)
                 {
                     decimal dcBalance = Convert.ToDecimal(rw["Debit"].ToString());
                     dcIndirectExpense += dcBalance;
                 }
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId1"].Value = "15";
             }
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcIndirectExpense.ToString();
             ///---Indirect Income
             dtblFinancial = new DataTable();
             dtblFinancial = DsetProfitAndLoss.Tables[5];
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Indirect Incomes";
             decimal dcIndirectIncome = 0m;
             if (dtblFinancial.Rows.Count > 0)
             {
                 foreach (DataRow rw in dtblFinancial.Rows)
                 {
                     decimal dcBalance = Convert.ToDecimal(rw["Credit"].ToString());
                     dcIndirectIncome += dcBalance;
                 }
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId2"].Value = "14";
             }
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcIndirectIncome.ToString();
             //---- Calculating Grand total
             decimal dcGrandTotalExpense = dcGrossLoss + dcIndirectExpense;
             decimal dcGrandTotalIncome  = dcGrossProfit + dcIndirectIncome;
             dgvProfitAndLoss.Rows.Add();
             dgvProfitAndLoss.Rows.Add();
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = "_______________________";
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = "_______________________";
             dgvProfitAndLoss.Rows.Add();
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Grand Total";
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value   = "Grand Total";
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].DefaultCellStyle.Font         = newFont;
             if (dcGrandTotalExpense > dcGrandTotalIncome)
             {
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value           = dcGrandTotalExpense.ToString();
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value           = dcGrandTotalExpense.ToString();
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtIncome"].Value            = "Net Loss ";
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount2"].Value           = dcGrandTotalExpense - dcGrandTotalIncome;
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtIncome"].Style.ForeColor  = Color.Red;
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount2"].Style.ForeColor = Color.Red;
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].DefaultCellStyle.Font = newFont;
                 decgranExTotal = dcGrandTotalExpense;
             }
             else
             {
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value            = dcGrandTotalIncome.ToString();
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value            = dcGrandTotalIncome.ToString();
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtExpenses"].Value           = "Net Profit";
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount1"].Value            = dcGrandTotalIncome - dcGrandTotalExpense;
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtExpenses"].Style.ForeColor = Color.Green;
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount1"].Style.ForeColor  = Color.Green;
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].DefaultCellStyle.Font = newFont;
                 decgranIncTotal = dcGrandTotalIncome;
             }
             if (dgvProfitAndLoss.Columns.Count > 0)
             {
                 dgvProfitAndLoss.Columns["dgvtxtAmount1"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                 dgvProfitAndLoss.Columns["dgvtxtAmount2"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
             }
             if (inCurrenRowIndex >= 0 && dgvProfitAndLoss.Rows.Count > 0 && inCurrenRowIndex < dgvProfitAndLoss.Rows.Count)
             {
                 if (dgvProfitAndLoss.Rows[inCurrenRowIndex].Cells[inCurrentColunIndex].Visible)
                 {
                     dgvProfitAndLoss.CurrentCell = dgvProfitAndLoss.Rows[inCurrenRowIndex].Cells[inCurrentColunIndex];
                 }
                 else
                 {
                     dgvProfitAndLoss.CurrentCell = dgvProfitAndLoss.Rows[inCurrenRowIndex].Cells["dgvtxtExpenses"];
                 }
                 dgvProfitAndLoss.CurrentCell.Selected = true;
             }
             inCurrenRowIndex = 0;
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "PAL1:" + ex.Message;
     }
 }
Exemple #25
0
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         if (!isFormLoad)
         {
             DateValidation objValidation = new DateValidation();
             objValidation.DateValidationFunction(txtFromDate);
             if (txtFromDate.Text == string.Empty)
                 txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy");
             objValidation.DateValidationFunction(txttoDate);
             if (txttoDate.Text == string.Empty)
                 txttoDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
             DateTime strFromDate = DateTime.Parse(txtFromDate.Text.ToString());
             DateTime strTodate = DateTime.Parse(txttoDate.Text.ToString());
             FinancialStatementSP spFinancial = new FinancialStatementSP();
             DataSet dsetFinancial = new DataSet();
             SettingsInfo InfoSettings = new SettingsInfo();
             SettingsSP SpSettings = new SettingsSP();
             dsetFinancial = spFinancial.CashFlow(strFromDate, strTodate);
             DataTable dtbl = new DataTable();
             Font newFont = new Font(dgvCashflow.Font, FontStyle.Bold);
             CurrencyInfo InfoCurrency = new CurrencyInfo();
             CurrencySP SpCurrency = new CurrencySP();
             InfoCurrency = SpCurrency.CurrencyView(1);
             int inDecimalPlaces = InfoCurrency.NoOfDecimalPlaces;
             dgvCashflow.Rows.Clear();
           
             for (int i = 0; i < 8; i++)
             {
                 dtbl = dsetFinancial.Tables[i];
                 foreach (DataRow rw in dtbl.Rows)
                 {
                     dgvCashflow.Rows.Add();
                     dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtParticulars"].Value = rw["accountGroupName"].ToString();
                     dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtinflow"].Value = rw["Balance"].ToString();
                     dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtID1"].Value = rw["accountGroupId"].ToString();
                 }
             }
             //-------------------------------Calculating TotalInflow-----------------------------------------
             decimal dcTotalInflow = 0m;
             if (dtbl.Rows.Count > 0)
             {
                 for (int i = 0; i < dgvCashflow.Rows.Count; i++)
                 {
                     decimal dcTotalIn = decimal.Parse(dgvCashflow.Rows[i].Cells["dgvtxtinflow"].Value.ToString());
                     dcTotalInflow += dcTotalIn;
                 }
                 dcTotInflow = dcTotalInflow;
             }
             //-----------------Outflow------------------------------
             int index = 0;
             for (int i = 8; i < 15; i++)
             {
                 dtbl = new DataTable();
                 dtbl = dsetFinancial.Tables[i];
                 foreach (DataRow rw in dtbl.Rows)
                 {
                     if (index < dgvCashflow.Rows.Count)
                     {
                         dgvCashflow.Rows[index].Cells["dgvtxtParticulars1"].Value = rw["accountGroupName1"].ToString();
                         dgvCashflow.Rows[index].Cells["dgvtxtoutflow"].Value = rw["Balance1"].ToString();
                         dgvCashflow.Rows[index].Cells["dgvtxtID2"].Value = rw["accountGroupId"].ToString();
                     }
                     else
                     {
                         dgvCashflow.Rows.Add();
                         dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtParticulars1"].Value = rw["accountGroupName1"].ToString();
                         dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtoutflow"].Value = rw["Balance1"].ToString();
                         dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtID2"].Value = rw["accountGroupId"].ToString();
                     }
                     index++;
                 }
             }
             //-------------------------------Calculating TotalOutflow-----------------------------------------
             decimal dcTotalOutflow = 0m;
             if (dtbl.Rows.Count > 0)
             {
                 for (int i = 0; i < dgvCashflow.Rows.Count - 1; i++)
                 {
                     decimal dcTotalIn = decimal.Parse(dgvCashflow.Rows[i].Cells["dgvtxtoutflow"].Value.ToString());
                     dcTotalOutflow += dcTotalIn;
                 }
                 dcTotOutflow = dcTotalOutflow;
             }
             dgvCashflow.Rows.Add();
             dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtinflow"].Value = "_______________________";
             dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtoutflow"].Value = "_______________________";
             dgvCashflow.Rows.Add();
             dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].DefaultCellStyle.Font = newFont;
             dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtParticulars"].Value = "Total";
             dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtParticulars1"].Value = "Total";
             dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtinflow"].Value = Math.Round((dcTotalInflow), inDecimalPlaces);
             dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtoutflow"].Value = Math.Round((dcTotalOutflow), inDecimalPlaces);
             if (dgvCashflow.Columns.Count > 0)
             {
                 dgvCashflow.Columns["dgvtxtinflow"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                 dgvCashflow.Columns["dgvtxtoutflow"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
             }
             if (inCurrenRowIndex >= 0 && dgvCashflow.Rows.Count > 0 && inCurrenRowIndex < dgvCashflow.Rows.Count)
             {
                 if (dgvCashflow.Rows[inCurrenRowIndex].Cells[inCurentcolIndex].Visible)
                 {
                     dgvCashflow.CurrentCell = dgvCashflow.Rows[inCurrenRowIndex].Cells[inCurentcolIndex];
                 }
                 if (dgvCashflow.CurrentCell != null && dgvCashflow.CurrentCell.Visible)
                     dgvCashflow.CurrentCell.Selected = true;
             }
             inCurrenRowIndex = 0;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("CF:01" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// ExportToThermalPrinter
        /// </summary>
        public void ExportToPDFforThermalPrinter()
        {
            iTextSharp.text.Document pdfdoc = new iTextSharp.text.Document();
            try
            {
                DirectoryInfo dir1 = new DirectoryInfo(Application.StartupPath + "\\Barcode");
                if (!Directory.Exists(Application.StartupPath + "\\Barcode"))
                {
                    dir1.Create();
                }
                if (File.Exists(Application.StartupPath + "\\Barcode\\Barcode.pdf"))
                {
                    File.Delete(Application.StartupPath + "\\Barcode\\Barcode.pdf");
                }
                iTextSharp.text.Rectangle pgSize = new iTextSharp.text.Rectangle(227, 65);
                pdfdoc = new Document(pgSize, 6, 6, 0, 0);
                PdfWriter writer = PdfWriter.GetInstance(pdfdoc, new FileStream(Application.StartupPath + "\\Barcode\\Barcode.pdf", FileMode.Create));
                PdfPTable tbl = new PdfPTable(2);
                float[] fltParentWidth = new float[] { 108f, 108f };
                tbl.TotalWidth = 216;
                tbl.LockedWidth = true;
                tbl.SetWidths(fltParentWidth);
                tbl.DefaultCell.FixedHeight = 57;
                tbl.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
                tbl.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
                tbl.DefaultCell.VerticalAlignment = Element.ALIGN_MIDDLE;
                pdfdoc.Open();
                int intotalCount = 0;
                BarcodeSettingsInfo Info = new BarcodeSettingsInfo();
                SettingsSP Sp = new SettingsSP();
                Info = spBarcodeSettings.BarcodeSettingsViewForBarCodePrinting();
                for (int i = 0; i < dgvBarcodePrinting.Rows.Count; i++) 
                {
                    if (dgvBarcodePrinting.Rows[i].Cells["dgvProductCode"].Value != null && dgvBarcodePrinting.Rows[i].Cells["dgvProductCode"].Value.ToString() != string.Empty)
                    {
                        int inCopies = 0;
                        if (dgvBarcodePrinting.Rows[i].Cells["dgvCopies"].Value != null)
                        {
                            int.TryParse(dgvBarcodePrinting.Rows[i].Cells["dgvCopies"].Value.ToString(), out inCopies); 
                        }
                        for (int j = 0; j < inCopies; j++)
                        {
                            string strCode = dgvBarcodePrinting.Rows[i].Cells["dgvProductCode"].Value.ToString();
                            string strCompanyName = string.Empty;
                            if (Info.ShowCompanyName)
                                strCompanyName = Info.CompanyName;
                            string strProductCode = string.Empty;
                            if (Info.ShowProductCode)
                                strProductCode = strCode;
                            else
                                strProductCode = dgvBarcodePrinting.Rows[i].Cells["dgvproductName"].Value.ToString();

                            string strMRP = string.Empty;
                            if (Info.ShowMRP)
                            {
                                strMRP = new CurrencySP().CurrencyView(PublicVariables._decCurrencyId).CurrencySymbol + ": " + dgvBarcodePrinting.Rows[i].Cells["dgvMRP"].Value.ToString();
                            }

                            string strSecretPurchaseRateCode = string.Empty;
                            if (Info.ShowPurchaseRate)
                            {
                                string strPurchaseRate = dgvBarcodePrinting.Rows[i].Cells["dgvPurchaseRate"].Value.ToString();
                              
                                if (strPurchaseRate.Contains("."))
                                {
                                    strPurchaseRate = strPurchaseRate.TrimEnd('0');
                                    if (strPurchaseRate[strPurchaseRate.Length - 1] == '.')
                                        strPurchaseRate = strPurchaseRate.Replace(".", "");
                                }
                                for (int k = 0; k < strPurchaseRate.Length; k++)
                                {
                                    switch (strPurchaseRate[k])
                                    {
                                        case '0':
                                            strSecretPurchaseRateCode += Info.Zero;
                                            break;
                                        case '1':
                                            strSecretPurchaseRateCode += Info.One;
                                            break;
                                        case '2':
                                            strSecretPurchaseRateCode += Info.Two;
                                            break;
                                        case '3':
                                            strSecretPurchaseRateCode += Info.Three;
                                            break;
                                        case '4':
                                            strSecretPurchaseRateCode += Info.Four;
                                            break;
                                        case '5':
                                            strSecretPurchaseRateCode += Info.Five;
                                            break;
                                        case '6':
                                            strSecretPurchaseRateCode += Info.Six;
                                            break;
                                        case '7':
                                            strSecretPurchaseRateCode += Info.Seven;
                                            break;
                                        case '8':
                                            strSecretPurchaseRateCode += Info.Eight;
                                            break;
                                        case '9':
                                            strSecretPurchaseRateCode += Info.Nine;
                                            break;
                                        case '.':
                                            strSecretPurchaseRateCode += Info.Point;
                                            break;
                                    }
                                }
                            }
                          
                            PdfContentByte pdfcb = writer.DirectContent;
                            Barcode128 code128 = new Barcode128();
                            code128.Code = strCode;
                            code128.Extended = false;
                            code128.CodeType = iTextSharp.text.pdf.Barcode.CODE128;
                            code128.AltText = strProductCode;
                            code128.BarHeight = 16;
                            code128.Size = 9;
                            code128.Baseline = 9;
                            code128.TextAlignment = Element.ALIGN_CENTER;
                            iTextSharp.text.Image image128 = code128.CreateImageWithBarcode(pdfcb, null, null);
                            Phrase phrase = new Phrase();
 
                            phrase.Add(new Chunk(strCompanyName, new iTextSharp.text.Font(-1, 9, iTextSharp.text.Font.BOLD)));
                            phrase.Add(new Chunk(Environment.NewLine + Environment.NewLine, new iTextSharp.text.Font(-1, 4)));
                            PdfPCell cell = new PdfPCell(phrase);
                            cell.HorizontalAlignment = Element.ALIGN_CENTER;
                            cell.VerticalAlignment = Element.ALIGN_MIDDLE;
                            cell.Border = iTextSharp.text.Rectangle.NO_BORDER;
                            phrase.Add(new Chunk(image128, 0, 0));
                            phrase.Add(new Chunk(Environment.NewLine, new iTextSharp.text.Font(-1, 4)));
                            phrase.Add(new Chunk(strMRP, new iTextSharp.text.Font(-1, 8)));
                            phrase.Add(new Chunk(Environment.NewLine + strSecretPurchaseRateCode, new iTextSharp.text.Font(-1, 7)));
                            phrase.Add(new Chunk(Environment.NewLine + Environment.NewLine, new iTextSharp.text.Font(-1, 1.2f)));
                            tbl.AddCell(cell);
                            intotalCount++; 
                        }
                    }
                }
                int reminder = intotalCount % 2;
                if (reminder != 0)
                {
                    for (int i = reminder; i < 2; ++i)
                    {
                        tbl.AddCell("");
                    }
                }
                if (tbl.Rows.Count != 0)
                {
                    pdfdoc.Add(tbl);
                    pdfdoc.Close();
                    System.Diagnostics.Process.Start(Application.StartupPath + "\\Barcode\\Barcode.pdf");
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("The process cannot access the file") && ex.Message.Contains("Barcode.pdf' because it is being used by another process."))
                {
                    MessageBox.Show("Close the PDF file and try again", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("BCP5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            finally
            {
                try
                {
                    pdfdoc.Close();
                }
                catch
                {
                }
            }
        }
        public void CalcTotalAmt()
        {
            string strCurrencySymbol = string.Empty;

            ExchangeRateSP SpExchangeRate = new ExchangeRateSP();
            CurrencySP SpCurrency = new CurrencySP();
            try
            {
                decimal decTotal = 0;
                if (dgvProduct.Rows.Count > 0)
                {
                    foreach (DataGridViewRow dgvrow in dgvProduct.Rows)
                    {
                        if (dgvrow.Cells["dgvtxtAmount"].Value != null && dgvrow.Cells["dgvtxtAmount"].Value.ToString() != "")
                        {
                            decTotal = decTotal + decimal.Parse(dgvrow.Cells["dgvtxtAmount"].Value.ToString());
                        }
                    }
                    txtTotalAmount.Text = decTotal.ToString();

                }
                else
                {
                    txtTotalAmount.Text = "0.00";

                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("RO:22" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to fill the grid
        /// </summary>
        public void GridFill()
        {
            try
            {

                CurrencyInfo InfoCurrency = new CurrencyInfo();
                CurrencySP SpCurrency = new CurrencySP();
                InfoCurrency = SpCurrency.CurrencyView(1);
                int inDecimalPlaces = InfoCurrency.NoOfDecimalPlaces;
                string calculationMethod = string.Empty;
                SettingsInfo InfoSettings = new SettingsInfo();
                SettingsSP SpSettings = new SettingsSP();
                //--------------- Selection Of Calculation Method According To Settings ------------------// 

                if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "FIFO")
                {
                    calculationMethod = "FIFO";
                }
                else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Average Cost")
                {
                    calculationMethod = "Average Cost";
                }
                else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "High Cost")
                {
                    calculationMethod = "High Cost";
                }
                else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Low Cost")
                {
                    calculationMethod = "Low Cost";
                }
                else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Last Purchase Rate")
                {
                    calculationMethod = "Last Purchase Rate";
                }

                StockPostingSP spstock = new StockPostingSP();
                decimal decrackId = 0;
                DataSet dsstock = new DataSet();
                DataTable dtbl = new DataTable();

                if (cmbRack.SelectedValue != null)
                {
                    decrackId = Convert.ToDecimal(cmbRack.SelectedValue.ToString());
                }

                dtbl = spstock.StockReportGridFill1(txtproductName.Text, Convert.ToDecimal(cmbBrand.SelectedValue.ToString()), Convert.ToDecimal(cmbModel.SelectedValue.ToString()), (txtProductCode.Text), Convert.ToDecimal(cmbGodown.SelectedValue.ToString()), decrackId, Convert.ToDecimal(cmbSize.SelectedValue.ToString()), Convert.ToDecimal(cmbTax.SelectedValue.ToString()), Convert.ToDecimal(cmbProductgroup.SelectedValue.ToString()), txtBatchName.Text);

                if (dtbl.Rows.Count > 0)
                {
                    decimal decTotal = 0;
                    for (int i = 0; i < dtbl.Rows.Count; i++)
                    {
                        if (dtbl.Rows[i]["stockvalue"].ToString() != string.Empty)
                        {
                            decTotal = decTotal + Convert.ToDecimal(dtbl.Rows[i]["stockvalue"].ToString());
                        }

                    }

                    decTotal = Math.Round(decTotal, 2);
                    txtTotal.Text = decTotal.ToString();
                }
                else
                {
                    txtTotal.Text = "0.00";
                }


                dgvStockReport.DataSource = dtbl;
                //if (dtbl.Columns.Count > 0)
                //{
                //    dgvStockReport.Columns["stockvalue"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                //}

            }
            catch (Exception ex)
            {
                MessageBox.Show("STKR:8" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Fill the corresponding details of party and calculations on cell value changed 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvPartyBalance_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                PartyBalanceSP SpPartyBalance = new PartyBalanceSP();
                
                
                if (e.RowIndex != -1 && e.ColumnIndex != -1)
                {
                    if (dgvPartyBalance.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value == null || dgvPartyBalance.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value.ToString() == string.Empty)
                    {
                        dgvPartyBalance.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(1);//decExchangeRateId;
                        
                    }
                    if (dgvPartyBalance.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvtxtAmount" || dgvPartyBalance.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbCurrency")
                    {
                        TotalAmount();
                    }
                    //---------------------check column missing---------------------------------//
                    CheckColumnMissing(e);
                    //==========================================================================//
                    if (dgvPartyBalance.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbReference")
                    {
                        if (dgvPartyBalance.CurrentRow.Cells["dgvcmbReference"].Value != null)//&& dgvPartyBalance.CurrentRow.Cells["dgvcmbReference"].Value.ToString() != string.Empty)
                        {
                            //to fill combo without filling the already selected value
                            if (dgvPartyBalance.CurrentRow.Cells["dgvcmbReference"].Value.ToString() == "Against")
                            {
                                dgvPartyBalance.CurrentRow.Cells["dgvcmbVoucherType"].ReadOnly = false;
                                if (frmJournalVoucherObj != null)
                                {
                                    dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = strDebitOrCredit;
                                }
                                else if (frmPaymentVoucherObj != null)
                                {
                                    dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Dr";
                                }
                                else if (frmReceiptVoucherObj != null)
                                {
                                    dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Cr";
                                }
                                else if (frmPdcpayableObj != null)
                                {
                                    dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Dr";
                                }
                                else if (frmPdcReceivableObj != null)
                                {
                                    dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Cr";
                                }
                            }
                            else if (dgvPartyBalance.CurrentRow.Cells["dgvcmbReference"].Value.ToString() == "New")
                            {
                                dgvPartyBalance.CurrentRow.Cells["dgvcmbVoucherType"].ReadOnly = true;
                                dgvPartyBalance.CurrentRow.Cells["dgvcmbVoucherType"].Value = string.Empty;
                                dgvPartyBalance.CurrentRow.Cells["dgvtxtVoucherNo"].Value = null;
                                dgvPartyBalance.CurrentRow.Cells["dgvtxtPending"].Value = null;
                                dgvPartyBalance.CurrentRow.Cells["dgvcmbCurrency"].ReadOnly = false;
                                if (frmJournalVoucherObj != null)
                                {
                                    dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = strDebitOrCredit;
                                }
                                else if (frmPaymentVoucherObj != null)
                                {
                                    dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Dr";
                                }
                                else if (frmReceiptVoucherObj != null)
                                {
                                    dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Cr";
                                }
                                else if (frmPdcpayableObj != null)
                                {
                                    dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Dr";
                                }
                                else if (frmPdcReceivableObj != null)
                                {
                                    dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Cr";
                                }
                            }
                            //
                            else if (dgvPartyBalance.CurrentRow.Cells["dgvcmbReference"].Value.ToString() == "OnAccount")
                            {
                                dgvPartyBalance.CurrentRow.Cells["dgvcmbVoucherType"].ReadOnly = true;
                                dgvPartyBalance.CurrentRow.Cells["dgvcmbVoucherType"].Value = string.Empty;
                                dgvPartyBalance.CurrentRow.Cells["dgvtxtVoucherNo"].Value = null;
                                dgvPartyBalance.CurrentRow.Cells["dgvtxtPending"].Value = null;
                                dgvPartyBalance.CurrentRow.Cells["dgvcmbCurrency"].ReadOnly = false;
                                if (frmJournalVoucherObj != null)
                                {
                                    dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = strDebitOrCredit;
                                }
                                else if (frmPaymentVoucherObj != null)
                                {
                                    dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Dr";
                                }
                                else if (frmReceiptVoucherObj != null)
                                {
                                    dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Cr";
                                }
                                else if (frmPdcpayableObj != null)
                                {
                                    dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Dr";
                                }
                                else if (frmPdcReceivableObj != null)
                                {
                                    dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Cr";
                                }
                            }
                        }
                    }
                    else if (dgvPartyBalance.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbVoucherType")
                    {
                        if (dgvPartyBalance.CurrentRow.Cells["dgvcmbVoucherType"].Value != null && dgvPartyBalance.CurrentRow.Cells["dgvcmbVoucherType"].Value.ToString().Trim() != string.Empty)
                        {
                            ExchangeRateSP spExchangeRate = new ExchangeRateSP();
                            ExchangeRateInfo infoExchangeRate = new ExchangeRateInfo();
                            string str = dgvPartyBalance.CurrentRow.Cells["dgvcmbVoucherType"].Value.ToString();
                            string[] words;
                            words = str.Split('_');
                            DataTable dtbl = new DataTable();
                            dtbl = SpPartyBalance.PartyBalanceComboViewByLedgerId(decLedgerId, strDebitOrCredit, decVoucherTypeId, strVoucherNo);
                            for (int inD = 0; inD < dtbl.Rows.Count; inD++)
                            {
                                if (dgvPartyBalance.Rows[e.RowIndex].Cells["dgvcmbVoucherType"].Value.ToString() == dtbl.Rows[inD]["value"].ToString())
                                {
                                    dgvPartyBalance.CurrentRow.Cells["dgvtxtVoucherNo"].Value = dtbl.Rows[inD]["voucherNo"].ToString();
                                    dgvPartyBalance.CurrentRow.Cells["dgvtxtPending"].Value = Math.Round(Convert.ToDecimal(dtbl.Rows[inD]["balance"].ToString()), PublicVariables._inNoOfDecimalPlaces);

                                    dgvPartyBalance.CurrentRow.Cells["dgvtxtOldExchangeRateId"].Value = dtbl.Rows[inD]["exchangeRateId"].ToString();
                                    if (Convert.ToDecimal(dtbl.Rows[inD]["exchangeRateId"].ToString()) != 1m)
                                    {
                                        infoExchangeRate = spExchangeRate.ExchangeRateView(Convert.ToDecimal(dtbl.Rows[inD]["exchangeRateId"].ToString()));
                                        decimal decCurrentExchangeRateId = spExchangeRate.GetExchangeRateId(infoExchangeRate.CurrencyId, dtmVoucherDate);
                                        if (decCurrentExchangeRateId == 0)
                                        {
                                            CurrencySP spCurrency = new CurrencySP();
                                            CurrencyInfo infoCurrency = new CurrencyInfo();
                                            infoCurrency = spCurrency.CurrencyView(infoExchangeRate.CurrencyId);
                                            dgvPartyBalance.CurrentRow.Cells["dgvcmbCurrency"].Value = decCurrentExchangeRateId;
                                            
                                            Messages.InformationMessage("Set ExchangeRate for "+infoCurrency.CurrencyName);
                                            
                                        }
                                        else
                                        {
                                            dgvPartyBalance.CurrentRow.Cells["dgvcmbCurrency"].Value = decCurrentExchangeRateId;
                                        }
                                    }
                                    else
                                    {
                                        dgvPartyBalance.CurrentRow.Cells["dgvcmbCurrency"].Value = 1m;
                                    }
                                    dgvPartyBalance.CurrentRow.Cells["dgvtxtInvoiceNo"].Value = dtbl.Rows[inD]["invoiceNo"].ToString();
                                }
                            }
                            dgvPartyBalance.CurrentRow.Cells["dgvtxtAmount"].Value = null;
                            dgvPartyBalance.CurrentRow.Cells["dgvcmbCurrency"].ReadOnly = true;
                        }
                        //to make voucherno,pendingamount,invoiceno,currency as null when vouchertype is selected as empty
                        else
                        {
                            dgvPartyBalance.CurrentRow.Cells["dgvtxtVoucherNo"].Value = null;
                            dgvPartyBalance.CurrentRow.Cells["dgvtxtPending"].Value = null;
                            dgvPartyBalance.CurrentRow.Cells["dgvtxtAmount"].Value = null;
                            dgvPartyBalance.CurrentRow.Cells["dgvtxtInvoiceNo"].Value = null;
                            dgvPartyBalance.CurrentRow.Cells["dgvcmbCurrency"].Value = null;
                            SettingsSP spSettings = new SettingsSP();
                            if (spSettings.SettingsStatusCheck("MultiCurrency") == "Yes")
                            {
                                dgvcmbCurrency.ReadOnly = false;
                            }
                            else
                            {
                                dgvcmbCurrency.ReadOnly = true;

                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PB:16" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// CurrencyComboFill
 /// </summary>
 public void CurrencyComboFill()
 {
     bool IsTrue = false;
     TransactionsGeneralFill TransactionGenerateFillObj = new TransactionsGeneralFill();
     try
     {
         IsTrue = true;
         DataTable dtbl = new DataTable();
         CurrencySP spCurrency = new CurrencySP();
         SettingsSP spSettings = new SettingsSP();
         dtbl = TransactionGenerateFillObj.CurrencyComboByDate(dtpDate.Value);
         cmbCurrency.DataSource = dtbl;
         cmbCurrency.DisplayMember = "currencyName";
         cmbCurrency.ValueMember = "exchangeRateId";
         cmbCurrency.SelectedValue = 1m;
         if (spSettings.SettingsStatusCheck("MultiCurrency") == "Yes")
         {
             cmbCurrency.Enabled = true;
         }
         else
         {
             cmbCurrency.Enabled = false;
         }
         IsTrue = false;
     }
     catch (Exception ex)
     {
         MessageBox.Show("DN32:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #31
0
 /// <summary>
 /// Function to fill controls for update
 /// </summary>
 public void FillControls()
 {
     try
     {
         CurrencyInfo infoCurrency = new CurrencyInfo();
         CurrencySP spCurrency = new CurrencySP();
         infoCurrency = spCurrency.CurrencyView(decId);
         txtName.Text = infoCurrency.CurrencyName;
         txtSymbol.Text = infoCurrency.CurrencySymbol;
         txtSubUnit.Text = infoCurrency.SubunitName;
         txtDecimalPlaces.Text = infoCurrency.NoOfDecimalPlaces.ToString();
         txtNarration.Text = infoCurrency.Narration;
         decCurrencyId = infoCurrency.CurrencyId;
     }
     catch (Exception ex)
     {
         MessageBox.Show("C4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function for Save
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         CompanyInfo infoCompany = new CompanyInfo();
         CompanySP spCompany = new CompanySP();
         CompanyPathInfo infoCompanyPath = new CompanyPathInfo();
         CompanyPathSP spCompanyPath = new CompanyPathSP();
         UserInfo infoUser = new UserInfo();
         UserSP spUser = new UserSP();
         ExchangeRateInfo infoExchangeRate = new ExchangeRateInfo();
         ExchangeRateSP spExchangeRate = new ExchangeRateSP();
         infoCompany.CompanyName = txtCompanyName.Text.Trim();
         infoCompany.MailingName = txtMailingName.Text.Trim();
         infoCompany.Address = txtAddress.Text.Trim();
         infoCompany.Phone = txtPhoneNo.Text.Trim();
         infoCompany.Mobile = txtMobile.Text.Trim();
         infoCompany.EmailId = txtEmail.Text.Trim();
         infoCompany.Web = txtWeb.Text.Trim();
         infoCompany.Country = txtCountry.Text.Trim();
         infoCompany.State = txtState.Text.Trim();
         infoCompany.Pin = txtPincode.Text.Trim();
         infoCompany.CurrencyId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
         decCurrencyIdForStatus = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
         infoCompany.FinancialYearFrom = Convert.ToDateTime(txtFinancialYearFrom.Text.Trim().ToString());
         infoCompany.BooksBeginingFrom = Convert.ToDateTime(txtBooksBegining.Text.Trim().ToString());
         infoCompany.Tin = txtTinNo.Text.Trim();
         infoCompany.Cst = txtCstNo.Text.Trim();
         infoCompany.Pan = txtPanNo.Text.Trim();
         infoCompany.CurrentDate = DateTime.Now;
         infoCompany.Logo = logo;
         infoCompany.Extra1 = string.Empty;
         infoCompany.Extra2 = string.Empty;
         infoCompanyPath.CompanyName = txtCompanyName.Text.Trim();
         infoCompanyPath.IsDefault = cbxSetAsDefault.Checked;
         infoCompanyPath.Extra1 = string.Empty;
         infoCompanyPath.Extra2 = string.Empty;
         infoUser.UserName = txtAdminUserName.Text.Trim();
         infoUser.Password = txtPassword.Text.Trim();
         infoUser.Active = true;
         infoUser.Extra1 = string.Empty;
         infoUser.Extra2 = string.Empty;
         infoUser.Narration = string.Empty;
         infoUser.RoleId = 1;
         if (spCompany.CompanyCheckExistence(txtCompanyName.Text.Trim().ToString(), 0) == false)
         {
             decimal decCompanyId = spCompany.CompanyAddParticularFeilds(infoCompany);
             PublicVariables._decCurrentCompanyId = decCompanyId;
             infoCompanyPath.CompanyPath = Application.StartupPath + "\\Data\\" + PublicVariables._decCurrentCompanyId;
             spCompanyPath.CompanyPathAdd(infoCompanyPath);
             if (formMDI.demoProject || CreateCompany())
             {
                 if (!formMDI.demoProject)
                 {
                     infoCompanyPath.CompanyPath = strPath;
                 }
                 else
                 {
                     infoCompanyPath.CompanyPath = Application.StartupPath + "\\Data";
                     PublicVariables._decCurrentCompanyId = 0;
                 }
                 CompanyInfo infoNewCompany = new CompanyInfo();
                 CompanySP spNewCompany = new CompanySP();
                 CompanyPathInfo infoNewCompanyPath = new CompanyPathInfo();
                 CompanyPathSP spNewCompanyPath = new CompanyPathSP();
                 UserInfo infoNewUser = new UserInfo();
                 UserSP spNewUser = new UserSP();
                 ExchangeRateInfo infoNewExchangeRate = new ExchangeRateInfo();
                 ExchangeRateSP spNewExchangeRate = new ExchangeRateSP();
                 infoNewCompany = infoCompany;
                 infoNewCompanyPath = infoCompanyPath;
                 infoNewUser = infoUser;
                 decCompanyId = spNewCompany.CompanyAddParticularFeilds(infoNewCompany);
                 spNewUser.UserAdd(infoNewUser);
                 spNewCompanyPath.CompanyPathAdd(infoNewCompanyPath);
                 Messages.SavedMessage();
                 formMDI.MDIObj.MenuStripEnabling();
                 //  To set default currencyId.............//
                 infoNewExchangeRate.CurrencyId = infoNewCompany.CurrencyId;
                 infoNewExchangeRate.Rate = 1;
                 infoNewExchangeRate.Narration = string.Empty;
                 infoNewExchangeRate.Extra1 = string.Empty;
                 infoNewExchangeRate.Extra2 = string.Empty;
                 infoNewExchangeRate.ExtraDate = System.DateTime.Now;
                 infoNewExchangeRate.Date = System.DateTime.Now;
                 spNewExchangeRate.ExchangeRateAdd(infoNewExchangeRate);
                 CurrencySP spCurrency = new CurrencySP();
                 spCurrency.DefaultCurrencySet(decCurrencyIdForStatus);
                 AfterCompanyCreation();
                 Clear();
                 this.Close();
             }
             else
             {
                 Messages.InformationMessage("Company creation failed");
             }
         }
         else
         {
             Messages.InformationMessage("Companyname already exist");
             txtCompanyName.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("CR1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #33
0
        /// <summary>
        /// ExportToThermalPrinter
        /// </summary>
        public void ExportToPDFforThermalPrinter()
        {
            iTextSharp.text.Document pdfdoc = new iTextSharp.text.Document();
            try
            {
                DirectoryInfo dir1 = new DirectoryInfo(Application.StartupPath + "\\Barcode");
                if (!Directory.Exists(Application.StartupPath + "\\Barcode"))
                {
                    dir1.Create();
                }
                if (File.Exists(Application.StartupPath + "\\Barcode\\Barcode.pdf"))
                {
                    File.Delete(Application.StartupPath + "\\Barcode\\Barcode.pdf");
                }
                iTextSharp.text.Rectangle pgSize = new iTextSharp.text.Rectangle(227, 65);
                pdfdoc = new Document(pgSize, 6, 6, 0, 0);
                PdfWriter writer         = PdfWriter.GetInstance(pdfdoc, new FileStream(Application.StartupPath + "\\Barcode\\Barcode.pdf", FileMode.Create));
                PdfPTable tbl            = new PdfPTable(2);
                float[]   fltParentWidth = new float[] { 108f, 108f };
                tbl.TotalWidth  = 216;
                tbl.LockedWidth = true;
                tbl.SetWidths(fltParentWidth);
                tbl.DefaultCell.FixedHeight         = 57;
                tbl.DefaultCell.Border              = iTextSharp.text.Rectangle.NO_BORDER;
                tbl.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
                tbl.DefaultCell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                pdfdoc.Open();
                int intotalCount         = 0;
                BarcodeSettingsInfo Info = new BarcodeSettingsInfo();
                SettingsSP          Sp   = new SettingsSP();
                Info = spBarcodeSettings.BarcodeSettingsViewForBarCodePrinting();
                for (int i = 0; i < dgvBarcodePrinting.Rows.Count; i++)
                {
                    if (dgvBarcodePrinting.Rows[i].Cells["dgvProductCode"].Value != null && dgvBarcodePrinting.Rows[i].Cells["dgvProductCode"].Value.ToString() != string.Empty)
                    {
                        int inCopies = 0;
                        if (dgvBarcodePrinting.Rows[i].Cells["dgvCopies"].Value != null)
                        {
                            int.TryParse(dgvBarcodePrinting.Rows[i].Cells["dgvCopies"].Value.ToString(), out inCopies);
                        }
                        for (int j = 0; j < inCopies; j++)
                        {
                            string strCode        = dgvBarcodePrinting.Rows[i].Cells["dgvProductCode"].Value.ToString();
                            string strCompanyName = string.Empty;
                            if (Info.ShowCompanyName)
                            {
                                strCompanyName = Info.CompanyName;
                            }
                            string strProductCode = string.Empty;
                            if (Info.ShowProductCode)
                            {
                                strProductCode = strCode;
                            }
                            else
                            {
                                strProductCode = dgvBarcodePrinting.Rows[i].Cells["dgvproductName"].Value.ToString();
                            }

                            string strMRP = string.Empty;
                            if (Info.ShowMRP)
                            {
                                strMRP = new CurrencySP().CurrencyView(PublicVariables._decCurrencyId).CurrencySymbol + ": " + dgvBarcodePrinting.Rows[i].Cells["dgvMRP"].Value.ToString();
                            }

                            string strSecretPurchaseRateCode = string.Empty;
                            if (Info.ShowPurchaseRate)
                            {
                                string strPurchaseRate = dgvBarcodePrinting.Rows[i].Cells["dgvPurchaseRate"].Value.ToString();

                                if (strPurchaseRate.Contains("."))
                                {
                                    strPurchaseRate = strPurchaseRate.TrimEnd('0');
                                    if (strPurchaseRate[strPurchaseRate.Length - 1] == '.')
                                    {
                                        strPurchaseRate = strPurchaseRate.Replace(".", "");
                                    }
                                }
                                for (int k = 0; k < strPurchaseRate.Length; k++)
                                {
                                    switch (strPurchaseRate[k])
                                    {
                                    case '0':
                                        strSecretPurchaseRateCode += Info.Zero;
                                        break;

                                    case '1':
                                        strSecretPurchaseRateCode += Info.One;
                                        break;

                                    case '2':
                                        strSecretPurchaseRateCode += Info.Two;
                                        break;

                                    case '3':
                                        strSecretPurchaseRateCode += Info.Three;
                                        break;

                                    case '4':
                                        strSecretPurchaseRateCode += Info.Four;
                                        break;

                                    case '5':
                                        strSecretPurchaseRateCode += Info.Five;
                                        break;

                                    case '6':
                                        strSecretPurchaseRateCode += Info.Six;
                                        break;

                                    case '7':
                                        strSecretPurchaseRateCode += Info.Seven;
                                        break;

                                    case '8':
                                        strSecretPurchaseRateCode += Info.Eight;
                                        break;

                                    case '9':
                                        strSecretPurchaseRateCode += Info.Nine;
                                        break;

                                    case '.':
                                        strSecretPurchaseRateCode += Info.Point;
                                        break;
                                    }
                                }
                            }

                            PdfContentByte pdfcb   = writer.DirectContent;
                            Barcode128     code128 = new Barcode128();
                            code128.Code          = strCode;
                            code128.Extended      = false;
                            code128.CodeType      = iTextSharp.text.pdf.Barcode.CODE128;
                            code128.AltText       = strProductCode;
                            code128.BarHeight     = 16;
                            code128.Size          = 9;
                            code128.Baseline      = 9;
                            code128.TextAlignment = Element.ALIGN_CENTER;
                            iTextSharp.text.Image image128 = code128.CreateImageWithBarcode(pdfcb, null, null);
                            Phrase phrase = new Phrase();

                            BaseFont bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);

                            phrase.Add(new Chunk(strCompanyName, new iTextSharp.text.Font(bfTimes, 9, iTextSharp.text.Font.BOLD)));
                            phrase.Add(new Chunk(Environment.NewLine + Environment.NewLine, new iTextSharp.text.Font(bfTimes, 4)));
                            PdfPCell cell = new PdfPCell(phrase);
                            cell.HorizontalAlignment = Element.ALIGN_CENTER;
                            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                            cell.Border = iTextSharp.text.Rectangle.NO_BORDER;
                            phrase.Add(new Chunk(image128, 0, 0));
                            phrase.Add(new Chunk(Environment.NewLine, new iTextSharp.text.Font(bfTimes, 4)));
                            phrase.Add(new Chunk(strMRP, new iTextSharp.text.Font(bfTimes, 8)));
                            phrase.Add(new Chunk(Environment.NewLine + strSecretPurchaseRateCode, new iTextSharp.text.Font(bfTimes, 7)));
                            phrase.Add(new Chunk(Environment.NewLine + Environment.NewLine, new iTextSharp.text.Font(bfTimes, 1.2f)));
                            tbl.AddCell(cell);
                            intotalCount++;
                        }
                    }
                }
                int reminder = intotalCount % 2;
                if (reminder != 0)
                {
                    for (int i = reminder; i < 2; ++i)
                    {
                        tbl.AddCell("");
                    }
                }
                if (tbl.Rows.Count != 0)
                {
                    pdfdoc.Add(tbl);
                    pdfdoc.Close();
                    System.Diagnostics.Process.Start(Application.StartupPath + "\\Barcode\\Barcode.pdf");
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("The process cannot access the file") && ex.Message.Contains("Barcode.pdf' because it is being used by another process."))
                {
                    MessageBox.Show("Close the PDF file and try again", "Openmiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    formMDI.infoError.ErrorString = "BCP5:" + ex.Message;
                }
            }
            finally
            {
                try
                {
                    pdfdoc.Close();
                }
                catch
                {
                }
            }
        }
Exemple #34
0
        /// <summary>
        /// Function to return amount in words
        /// </summary>
        /// <param name="decAmount"></param>
        /// <param name="decCurrId"></param>
        /// <returns></returns>
        public string AmountWords(decimal decAmount, decimal decCurrId)
        {
            string       AountInWords = string.Empty; // To return the amount in words
            CurrencyInfo currencyInfo = new CurrencySP().CurrencyView(decCurrId);

            decAmount = Math.Round(decAmount, currencyInfo.NoOfDecimalPlaces); //Rounding according to decimal places of currency
            string strAmount = decAmount.ToString();                           // Just keeping the whole amount as string for performing split operation on it
            string strAmountinwordsOfIntiger = string.Empty;                   // To hold amount in words of intiger
            string strAmountInWordsOfDecimal = string.Empty;                   // To hold amoutn in words of decimal part

            string[] strPartsArray = strAmount.Split('.');                     // Splitting with "." to get intiger part and decimal part seperately
            string   strDecimaPart = string.Empty;                             // To hold decimal part

            if (strPartsArray.Length > 1)
            {
                if (strPartsArray[1] != null)
                {
                    strDecimaPart = strPartsArray[1]; // Holding decimal portion if any
                }
            }
            if (strPartsArray[0] != null)
            {
                strAmount = strPartsArray[0];    // Holding intiger part of amount
            }
            else
            {
                strAmount = string.Empty;
            };
            if (strAmount.Trim() != string.Empty && decimal.Parse(strAmount) != 0)
            {
                strAmountinwordsOfIntiger = NumberToText(long.Parse(strAmount));
            }
            if (strDecimaPart.Trim() != string.Empty && decimal.Parse(strDecimaPart) != 0)
            {
                strAmountInWordsOfDecimal = NumberToText(long.Parse(strDecimaPart));
            }
            SettingsSP spSettings = new SettingsSP();
            if (spSettings.SettingsStatusCheck("ShowCurrencySymbol") != "Yes")
            {
                // Showing currency as suffix
                if (strAmountinwordsOfIntiger != string.Empty)
                {
                    AountInWords = strAmountinwordsOfIntiger + " " + currencyInfo.CurrencyName;
                }
                if (strAmountInWordsOfDecimal != string.Empty)
                {
                    AountInWords = AountInWords + " and " + strAmountInWordsOfDecimal + " " + currencyInfo.SubunitName;
                }
                AountInWords = AountInWords + " only";
            }
            else
            {
                // Showing currency as prefix
                if (strAmountinwordsOfIntiger != string.Empty)
                {
                    AountInWords = currencyInfo.CurrencyName + " " + strAmountinwordsOfIntiger;
                }
                if (strAmountInWordsOfDecimal != string.Empty)
                {
                    AountInWords = AountInWords + " and " + currencyInfo.SubunitName + " " + strAmountInWordsOfDecimal;
                }
                AountInWords = AountInWords + " only";
            }
            return(AountInWords);
        }
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void Gridfill()
 {
     try
     {
         if (!isFormLoad)
         {
             DateValidation objValidation = new DateValidation();
             objValidation.DateValidationFunction(txtFromDate);
             if (txtFromDate.Text == string.Empty)
                 txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy");
             objValidation.DateValidationFunction(txtToDate);
             if (txtToDate.Text == string.Empty)
                 txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
             Font newFont = new Font(dgvProfitAndLoss.Font, FontStyle.Bold);
             CurrencyInfo InfoCurrency = new CurrencyInfo();
             CurrencySP SpCurrency = new CurrencySP();
             InfoCurrency = SpCurrency.CurrencyView(1);
             int inDecimalPlaces = InfoCurrency.NoOfDecimalPlaces;
             dgvProfitAndLoss.Rows.Clear();
             FinancialStatementSP spFinancial = new FinancialStatementSP();
             DataTable dtblFinancial = new DataTable();
             DataSet DsetProfitAndLoss = new DataSet();
             SettingsInfo infoSettings = new SettingsInfo();
             SettingsSP SpSettings = new SettingsSP();
             //---------check  calculation method
             if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "FIFO")
             {
                 calculationMethod = "FIFO";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Average Cost")
             {
                 calculationMethod = "Average Cost";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "High Cost")
             {
                 calculationMethod = "High Cost";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Low Cost")
             {
                 calculationMethod = "Low Cost";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Last Purchase Rate")
             {
                 calculationMethod = "Last Purchase Rate";
             }
             DsetProfitAndLoss = spFinancial.ProfitAndLossAnalysis(DateTime.Parse(txtFromDate.Text), DateTime.Parse(txtToDate.Text));
             //---- Opening Stock
             dgvProfitAndLoss.Rows.Add();
             decimal dcOpeningStock = spFinancial.StockValueGetOnDate(DateTime.Parse(txtFromDate.Text), DateTime.Parse(txtToDate.Text), calculationMethod, true, false);
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Opening Stock";
             if (dcOpeningStock > 0)
             {
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = Math.Round(dcOpeningStock, inDecimalPlaces);
             }
             else
             {
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = -(Math.Round(dcOpeningStock, inDecimalPlaces));
             }
             //Closing Stock 
             decimal dcClosingStock = 0;
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Closing Stock";
             dcClosingStock = spFinancial.StockValueGetOnDate(DateTime.Parse(txtToDate.Text), calculationMethod, false, false);
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = Math.Round(dcClosingStock, inDecimalPlaces);
             /// ---Purchase Account  - Debit
             dtblFinancial = new DataTable();
             dtblFinancial = DsetProfitAndLoss.Tables[0];
             dgvProfitAndLoss.Rows.Add();
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Purchase Accounts";
             decimal dcPurchaseAccount = 0m;
             if (dtblFinancial.Rows.Count > 0)
             {
                 foreach (DataRow rw in dtblFinancial.Rows)
                 {
                     decimal dcBalance = decimal.Parse(rw["Debit"].ToString().ToString());
                     dcPurchaseAccount += dcBalance;
                 }
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId1"].Value = "11";
             }
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcPurchaseAccount.ToString();
             //---Sales Account  -Credit
             dtblFinancial = new DataTable();
             dtblFinancial = DsetProfitAndLoss.Tables[1];
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Sales Accounts";
             decimal dcSalesAccount = 0m;
             if (dtblFinancial.Rows.Count > 0)
             {
                 foreach (DataRow rw in dtblFinancial.Rows)
                 {
                     decimal dcBalance = decimal.Parse(rw["Credit"].ToString().ToString());
                     dcSalesAccount += dcBalance;
                 }
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId2"].Value = "10";
             }
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcSalesAccount.ToString();
             dgvProfitAndLoss.Rows.Add();
             dgvProfitAndLoss.Rows.Add();
             //---Direct Expense
             dtblFinancial = new DataTable();
             dtblFinancial = DsetProfitAndLoss.Tables[2];
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Direct Expenses";
             decimal dcDirectExpense = 0m;
             if (dtblFinancial.Rows.Count > 0)
             {
                 foreach (DataRow rw in dtblFinancial.Rows)
                 {
                     decimal dcBalance = Convert.ToDecimal(rw["Debit"].ToString());
                     dcDirectExpense += dcBalance;
                 }
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId1"].Value = "13";
             }
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcDirectExpense.ToString();
             //----Direct Income 
             dtblFinancial = new DataTable();
             dtblFinancial = DsetProfitAndLoss.Tables[3];
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Direct Incomes";
             decimal dcDirectIncoome = 0m;
             if (dtblFinancial.Rows.Count > 0)
             {
                 foreach (DataRow rw in dtblFinancial.Rows)
                 {
                     decimal dcBalance = Convert.ToDecimal(rw["Credit"].ToString());
                     dcDirectIncoome += dcBalance;
                 }
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId2"].Value = "12";
             }
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcDirectIncoome.ToString();
             dgvProfitAndLoss.Rows.Add();
             dgvProfitAndLoss.Rows.Add();
             dgvProfitAndLoss.Rows.Add();
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = "_______________________";
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = "_______________________";
             dgvProfitAndLoss.Rows.Add();
             decimal dcTotalExpense = 0;
             decimal dcTotalIncome = 0;
             dcTotalExpense = dcOpeningStock + dcPurchaseAccount + dcDirectExpense;
             dcTotalIncome = dcClosingStock + dcSalesAccount + dcDirectIncoome;
             dcTotalExpense = Math.Round(dcTotalExpense, inDecimalPlaces);
             dcTotalIncome = Math.Round(dcTotalIncome, inDecimalPlaces);
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].DefaultCellStyle.Font = newFont;
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Total";
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Total";
             decimal dcGrossProfit = 0;
             decimal dcGrossLoss = 0;
             if (dcTotalExpense > dcTotalIncome)
             {
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcTotalExpense.ToString();
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcTotalExpense.ToString();
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtIncome"].Value = "Gross Loss b/d ";
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount2"].Value = dcTotalExpense - dcTotalIncome;
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount2"].Style.ForeColor = Color.Red;
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtIncome"].Style.ForeColor = Color.Red;
                 dgvProfitAndLoss.Rows.Add();
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Gross Loss b/d ";
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcTotalExpense - dcTotalIncome;
                 dcGrossLoss = dcTotalExpense - dcTotalIncome;
             }
             else
             {
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcTotalIncome.ToString();
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcTotalIncome.ToString();
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtExpenses"].Value = "Gross Profit c/d ";
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount1"].Value = dcTotalIncome - dcTotalExpense;
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount1"].Style.ForeColor = Color.Green;
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtExpenses"].Style.ForeColor = Color.Green;
                 dgvProfitAndLoss.Rows.Add();
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Gross Profit c/d ";
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcTotalIncome - dcTotalExpense;
                 dcGrossProfit = dcTotalIncome - dcTotalExpense;
             }
             dgvProfitAndLoss.Rows.Add();
             ///------Indirect Expense 
             dtblFinancial = new DataTable();
             dtblFinancial = DsetProfitAndLoss.Tables[4];
             dgvProfitAndLoss.Rows.Add();
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Indirect Expenses";
             decimal dcIndirectExpense = 0;
             if (dtblFinancial.Rows.Count > 0)
             {
                 foreach (DataRow rw in dtblFinancial.Rows)
                 {
                     decimal dcBalance = Convert.ToDecimal(rw["Debit"].ToString());
                     dcIndirectExpense += dcBalance;
                 }
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId1"].Value = "15";
             }
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcIndirectExpense.ToString();
             ///---Indirect Income 
             dtblFinancial = new DataTable();
             dtblFinancial = DsetProfitAndLoss.Tables[5];
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Indirect Incomes";
             decimal dcIndirectIncome = 0m;
             if (dtblFinancial.Rows.Count > 0)
             {
                 foreach (DataRow rw in dtblFinancial.Rows)
                 {
                     decimal dcBalance = Convert.ToDecimal(rw["Credit"].ToString());
                     dcIndirectIncome += dcBalance;
                 }
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId2"].Value = "14";
             }
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcIndirectIncome.ToString();
             //---- Calculating Grand total
             decimal dcGrandTotalExpense = dcGrossLoss + dcIndirectExpense;
             decimal dcGrandTotalIncome = dcGrossProfit + dcIndirectIncome;
             dgvProfitAndLoss.Rows.Add();
             dgvProfitAndLoss.Rows.Add();
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = "_______________________";
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = "_______________________";
             dgvProfitAndLoss.Rows.Add();
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Grand Total";
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Grand Total";
             dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].DefaultCellStyle.Font = newFont;
             if (dcGrandTotalExpense > dcGrandTotalIncome)
             {
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcGrandTotalExpense.ToString();
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcGrandTotalExpense.ToString();
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtIncome"].Value = "Net Loss ";
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount2"].Value = dcGrandTotalExpense - dcGrandTotalIncome;
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtIncome"].Style.ForeColor = Color.Red;
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount2"].Style.ForeColor = Color.Red;
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].DefaultCellStyle.Font = newFont;
                 decgranExTotal = dcGrandTotalExpense;
             }
             else
             {
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcGrandTotalIncome.ToString();
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcGrandTotalIncome.ToString();
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtExpenses"].Value = "Net Profit";
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount1"].Value = dcGrandTotalIncome - dcGrandTotalExpense;
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtExpenses"].Style.ForeColor = Color.Green;
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount1"].Style.ForeColor = Color.Green;
                 dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].DefaultCellStyle.Font = newFont;
                 decgranIncTotal = dcGrandTotalIncome;
             }
             if (dgvProfitAndLoss.Columns.Count > 0)
             {
                 dgvProfitAndLoss.Columns["dgvtxtAmount1"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                 dgvProfitAndLoss.Columns["dgvtxtAmount2"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
             }
             if (inCurrenRowIndex >= 0 && dgvProfitAndLoss.Rows.Count > 0 && inCurrenRowIndex < dgvProfitAndLoss.Rows.Count)
             {
                 if (dgvProfitAndLoss.Rows[inCurrenRowIndex].Cells[inCurrentColunIndex].Visible)
                 {
                     dgvProfitAndLoss.CurrentCell = dgvProfitAndLoss.Rows[inCurrenRowIndex].Cells[inCurrentColunIndex];
                 }
                 else
                 {
                     dgvProfitAndLoss.CurrentCell = dgvProfitAndLoss.Rows[inCurrenRowIndex].Cells["dgvtxtExpenses"];
                 }
                 dgvProfitAndLoss.CurrentCell.Selected = true;
             }
             inCurrenRowIndex = 0;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PAL :01" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Cleare Function, The form will be reset here
 /// </summary>
 public void ClearFunction()
 {
     try
     {
         CurrencySP SpCurrency = new CurrencySP();
         CurrencyInfo InfoCurrency = new CurrencyInfo();
         isInEditMode = false;
         VoucherNumberGeneration();
         FinancialYearDate();
         dtpVoucherDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         dtpcheckdate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         txtVoucherDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         btnDelete.Enabled = false;
         btnAgainRef.Enabled = false;
         cmbBankAccountFill();
         cmbAccountNameFill();
         txtAmount.Clear();
         txtAmount.Enabled = true;
         txtcheckNo.Clear();
         PrintCheck();
         txtNarration.Clear();
         dtblPartyBalance.Clear();
         btnSave.Text = "Save";
         if (!txtVoucherNo.ReadOnly)
         {
             txtVoucherNo.Focus();
         }
         else
         {
             txtVoucherDate.Select();
         }
         if (!btnAgainRef.Enabled)
         {
             txtAmount.ReadOnly = false;
         }
         else
         {
             txtAmount.ReadOnly = true;
         }
         if (PDCReceivableReportObj != null)
         {
             PDCReceivableReportObj.Close();
         }
         if (PDCReceivableRegisterObj != null)
         {
             PDCReceivableRegisterObj.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PR4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill Currency combobox
 /// </summary>
 public void CurrencyComboFill()
 {
     try
     {
         CurrencySP spCurrency = new CurrencySP();
         DataTable dtblCurrency = new DataTable();
         dtblCurrency = spCurrency.CurrencyViewAllForCombo();
         cmbCurrency.DataSource = dtblCurrency;
         cmbCurrency.ValueMember = "currencyId";
         cmbCurrency.DisplayMember = "currencyName";
     }
     catch (Exception ex)
     {
         MessageBox.Show("CR6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #38
0
        /// <summary>
        /// Function to fill the grid
        /// </summary>
        public void GridFill()
        {
            try
            {
                CurrencyInfo InfoCurrency = new CurrencyInfo();
                CurrencySP   SpCurrency   = new CurrencySP();
                InfoCurrency = SpCurrency.CurrencyView(1);
                int          inDecimalPlaces   = InfoCurrency.NoOfDecimalPlaces;
                string       calculationMethod = string.Empty;
                SettingsInfo InfoSettings      = new SettingsInfo();
                SettingsSP   SpSettings        = new SettingsSP();
                //--------------- Selection Of Calculation Method According To Settings ------------------//

                if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "FIFO")
                {
                    calculationMethod = "FIFO";
                }
                else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Average Cost")
                {
                    calculationMethod = "Average Cost";
                }
                else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "High Cost")
                {
                    calculationMethod = "High Cost";
                }
                else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Low Cost")
                {
                    calculationMethod = "Low Cost";
                }
                else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Last Purchase Rate")
                {
                    calculationMethod = "Last Purchase Rate";
                }

                StockPostingSP spstock   = new StockPostingSP();
                decimal        decrackId = 0;
                DataSet        dsstock   = new DataSet();
                DataTable      dtbl      = new DataTable();

                if (cmbRack.SelectedValue != null)
                {
                    decrackId = Convert.ToDecimal(cmbRack.SelectedValue.ToString());
                }

                dtbl = spstock.StockReportGridFill1(txtproductName.Text, Convert.ToDecimal(cmbBrand.SelectedValue.ToString()), Convert.ToDecimal(cmbModel.SelectedValue.ToString()), (txtProductCode.Text), Convert.ToDecimal(cmbGodown.SelectedValue.ToString()), decrackId, Convert.ToDecimal(cmbSize.SelectedValue.ToString()), Convert.ToDecimal(cmbTax.SelectedValue.ToString()), Convert.ToDecimal(cmbProductgroup.SelectedValue.ToString()), txtBatchName.Text);

                if (dtbl.Rows.Count > 0)
                {
                    decimal decTotal = 0;
                    for (int i = 0; i < dtbl.Rows.Count; i++)
                    {
                        if (dtbl.Rows[i]["stockvalue"].ToString() != string.Empty)
                        {
                            decTotal = decTotal + Convert.ToDecimal(dtbl.Rows[i]["stockvalue"].ToString());
                        }
                    }

                    decTotal      = Math.Round(decTotal, 2);
                    txtTotal.Text = decTotal.ToString();
                }
                else
                {
                    txtTotal.Text = "0.00";
                }


                dgvStockReport.DataSource = dtbl;
                //if (dtbl.Columns.Count > 0)
                //{
                //    dgvStockReport.Columns["stockvalue"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show("STKR:8" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void FillGrid()
 {
     try
     {
         if (!isFormLoad)
         {
             DateValidation objValidation = new DateValidation();
             objValidation.DateValidationFunction(txtToDate);
             if (txtToDate.Text == string.Empty)
             {
                 txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
             }
             Font         newFont      = new Font(dgvReport.Font, FontStyle.Bold);
             CurrencyInfo InfoCurrency = new CurrencyInfo();
             CurrencySP   SpCurrency   = new CurrencySP();
             InfoCurrency = SpCurrency.CurrencyView(1);
             int inDecimalPlaces = InfoCurrency.NoOfDecimalPlaces;
             dgvReport.Rows.Clear();
             FinancialStatementSP SpFinance = new FinancialStatementSP();
             DataSet      DsetBalanceSheet  = new DataSet();
             DataTable    dtbl         = new DataTable();
             SettingsInfo InfoSettings = new SettingsInfo();
             SettingsSP   SpSettings   = new SettingsSP();
             //--------------- Selection Of Calculation Method According To Settings ------------------//
             if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "FIFO")
             {
                 calculationMethod = "FIFO";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Average Cost")
             {
                 calculationMethod = "Average Cost";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "High Cost")
             {
                 calculationMethod = "High Cost";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Low Cost")
             {
                 calculationMethod = "Low Cost";
             }
             else if (SpSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Last Purchase Rate")
             {
                 calculationMethod = "Last Purchase Rate";
             }
             DsetBalanceSheet = SpFinance.BalanceSheet(PublicVariables._dtFromDate, DateTime.Parse(txtToDate.Text));
             //------------------- Asset -------------------------------//
             dtbl = DsetBalanceSheet.Tables[0];
             foreach (DataRow rw in dtbl.Rows)
             {
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = rw["Name"].ToString();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value     = rw["Balance"].ToString();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["GroupId1"].Value    = rw["ID"].ToString();
             }
             decimal dcTotalAsset = 0;
             if (dtbl.Rows.Count > 0)
             {
                 dcTotalAsset = decimal.Parse(dtbl.Compute("Sum(Balance)", string.Empty).ToString());
             }
             //------------------------ Liability ---------------------//
             dtbl = new DataTable();
             dtbl = DsetBalanceSheet.Tables[1];
             int index = 0;
             foreach (DataRow rw in dtbl.Rows)
             {
                 if (index < dgvReport.Rows.Count)
                 {
                     dgvReport.Rows[index].Cells["dgvtxtLiability"].Value = rw["Name"].ToString();
                     dgvReport.Rows[index].Cells["Amount2"].Value         = rw["Balance"].ToString();
                     dgvReport.Rows[index].Cells["GroupId2"].Value        = rw["ID"].ToString();
                 }
                 else
                 {
                     dgvReport.Rows.Add();
                     dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = rw["Name"].ToString();
                     dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value         = rw["Balance"].ToString();
                     dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["GroupId2"].Value        = rw["ID"].ToString();
                 }
                 index++;
             }
             decimal dcTotalLiability = 0;
             if (dtbl.Rows.Count > 0)
             {
                 dcTotalLiability = decimal.Parse(dtbl.Compute("Sum(Balance)", string.Empty).ToString());
             }
             decimal dcClosingStock = SpFinance.StockValueGetOnDate(Convert.ToDateTime(txtToDate.Text), calculationMethod, false, false);
             dcClosingStock = Math.Round(dcClosingStock, inDecimalPlaces);
             //---------------------Opening Stock---------------------------------------------------------------------------------------------------------------
             decimal dcOpeninggStock   = SpFinance.StockValueGetOnDate(PublicVariables._dtFromDate, calculationMethod, true, true);
             decimal dcProfit          = 0;
             DataSet dsetProfitAndLoss = new DataSet();
             dsetProfitAndLoss = SpFinance.ProfitAndLossAnalysisUpToaDateForBalansheet(PublicVariables._dtFromDate, DateTime.Parse(txtToDate.Text));
             DataTable dtblProfit = new DataTable();
             dtblProfit = dsetProfitAndLoss.Tables[0];
             for (int i = 0; i < dsetProfitAndLoss.Tables.Count; ++i)
             {
                 dtbl = dsetProfitAndLoss.Tables[i];
                 decimal dcSum = 0;
                 if (i == 0 || (i % 2) == 0)
                 {
                     if (dtbl.Rows.Count > 0)
                     {
                         dcSum    = decimal.Parse(dtbl.Compute("Sum(Debit)", string.Empty).ToString());
                         dcProfit = dcProfit - dcSum;
                     }
                 }
                 else
                 {
                     if (dtbl.Rows.Count > 0)
                     {
                         dcSum    = decimal.Parse(dtbl.Compute("Sum(Credit)", string.Empty).ToString());
                         dcProfit = dcProfit + dcSum;
                     }
                 }
             }
             decimal decCurrentProfitLoss = 0;
             decCurrentProfitLoss = dcProfit + (dcClosingStock - dcOpeninggStock);
             decimal dcProfitOpening          = 0;
             DataSet dsetProfitAndLossOpening = new DataSet();
             dsetProfitAndLossOpening = SpFinance.ProfitAndLossAnalysisUpToaDateForPreviousYears(PublicVariables._dtFromDate);
             DataTable dtblProfitOpening = new DataTable();
             dtblProfitOpening = dsetProfitAndLossOpening.Tables[0];
             for (int i = 0; i < dsetProfitAndLossOpening.Tables.Count; ++i)
             {
                 dtbl = dsetProfitAndLossOpening.Tables[i];
                 decimal dcSum = 0;
                 if (i == 0 || (i % 2) == 0)
                 {
                     if (dtbl.Rows.Count > 0)
                     {
                         dcSum           = decimal.Parse(dtbl.Compute("Sum(Debit)", string.Empty).ToString());
                         dcProfitOpening = dcProfitOpening - dcSum;
                     }
                 }
                 else
                 {
                     if (dtbl.Rows.Count > 0)
                     {
                         dcSum           = decimal.Parse(dtbl.Compute("Sum(Credit)", string.Empty).ToString());
                         dcProfitOpening = dcProfitOpening + dcSum;
                     }
                 }
             }
             DataTable dtblProfitLedgerOpening = new DataTable();
             dtblProfitLedgerOpening = DsetBalanceSheet.Tables[3];
             decimal decProfitLedgerOpening = 0;
             foreach (DataRow dRow in dtblProfitLedgerOpening.Rows)
             {
                 decProfitLedgerOpening += decimal.Parse(dRow["Balance"].ToString());
             }
             DataTable dtblProf = new DataTable();
             dtblProf = DsetBalanceSheet.Tables[2];
             decimal decProfitLedger = 0;
             if (dtblProf.Rows.Count > 0)
             {
                 decProfitLedger = decimal.Parse(dtblProf.Compute("Sum(Balance)", string.Empty).ToString());
             }
             decimal decTotalProfitAndLoss = 0;
             if (dcProfitOpening >= 0)
             {
                 decTotalProfitAndLoss = decProfitLedger;
             }
             else if (dcProfitOpening < 0)
             {
                 decTotalProfitAndLoss = decProfitLedger;
             }
             index = 0;
             if (dcClosingStock >= 0)
             {
                 //---------- Asset ----------//
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = "Closing Stock";
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value     = Math.Round(dcClosingStock, inDecimalPlaces);
                 dcTotalAsset += dcClosingStock;
             }
             else
             {
                 //--------- Liability ---------//
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = "Closing Stock";
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value         = -(Math.Round(dcClosingStock, inDecimalPlaces));
                 dcTotalLiability += -dcClosingStock;
             }
             dgvReport.Rows.Add();
             decimal decOpeningOfProfitAndLoss    = decProfitLedgerOpening + dcProfitOpening;
             decimal decTotalProfitAndLossOverAll = decTotalProfitAndLoss + decOpeningOfProfitAndLoss + decCurrentProfitLoss;
             if (decTotalProfitAndLossOverAll <= 0)
             {
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = "----------------------------------------";
                 dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font      = newFont;
                 foreach (DataRow dRow in dtblProf.Rows)
                 {
                     if (dRow["Name"].ToString() == "Profit And Loss Account")
                     {
                         dgvReport.Rows.Add();
                         dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font      = newFont;
                         dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.DarkSlateGray;
                         dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = dRow["Name"].ToString();
                         if (decCurrentProfitLoss < 0)
                         {
                             decCurrentProfitLoss = decCurrentProfitLoss * -1;
                         }
                         dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value  = Math.Round(decTotalProfitAndLoss + decCurrentProfitLoss, PublicVariables._inNoOfDecimalPlaces);
                         dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["GroupId1"].Value = dRow["ID"].ToString();
                     }
                 }
                 //-------------- Asset ---------------//
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font                = newFont;
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value           = "Profit And Loss (Opening)";
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value               = Math.Round(decTotalProfitAndLoss, PublicVariables._inNoOfDecimalPlaces);
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Style.ForeColor     = Color.DarkSlateGray;
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Style.ForeColor = Color.DarkSlateGray;
                 //-------------- Asset ---------------//
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font                = newFont;
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value           = "Current Period";
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value               = Math.Round(decCurrentProfitLoss, PublicVariables._inNoOfDecimalPlaces);
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Style.ForeColor     = Color.DarkSlateGray;
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Style.ForeColor = Color.DarkSlateGray;
                 dcTotalAsset = dcTotalAsset + (decCurrentProfitLoss + decTotalProfitAndLoss);
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = "----------------------------------------";
                 dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font      = newFont;
             }
             else if (decTotalProfitAndLossOverAll > 0)
             {
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = "----------------------------------------";
                 dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font          = newFont;
                 foreach (DataRow dRow in dtblProf.Rows)
                 {
                     if (dRow["Name"].ToString() == "Profit And Loss Account")
                     {
                         dgvReport.Rows.Add();
                         dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font          = newFont;
                         dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.ForeColor     = Color.DarkSlateGray;
                         dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = dRow[1].ToString();
                         dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value         = Math.Round(decTotalProfitAndLoss + decCurrentProfitLoss, PublicVariables._inNoOfDecimalPlaces);
                         dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["GroupId2"].Value        = dRow[0].ToString();
                     }
                 }
                 //------------ Liability ------------//
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font                    = newFont;
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value           = "Profit And Loss (Opening)";
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value                   = Math.Round(decTotalProfitAndLoss, inDecimalPlaces);
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Style.ForeColor         = Color.DarkSlateGray;
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Style.ForeColor = Color.DarkSlateGray;
                 dcTotalLiability += decOpeningOfProfitAndLoss;
                 //------------ Liability ------------//
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font                    = newFont;
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value           = "Current Period";
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value                   = Math.Round(decCurrentProfitLoss, inDecimalPlaces);
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Style.ForeColor         = Color.DarkSlateGray;
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Style.ForeColor = Color.DarkSlateGray;
                 dcTotalLiability = dcTotalLiability + (decCurrentProfitLoss + decTotalProfitAndLoss); //dcProfit;
                 dgvReport.Rows.Add();
                 dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = "----------------------------------------";
                 dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font          = newFont;
             }
             dgvReport.Rows.Add();
             decimal dcDiffAsset     = 0;
             decimal dcDiffLiability = 0;
             decimal dcTotalValue    = dcTotalAsset;
             if (dcTotalAsset != dcTotalLiability)
             {
                 if (dcTotalAsset > dcTotalLiability)
                 {
                     //--------------- Liability exceeds so in asset side ----------------//
                     dgvReport.Rows.Add();
                     dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = "Difference";
                     dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value         = Math.Round((dcTotalAsset - dcTotalLiability), inDecimalPlaces);
                     dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font          = newFont;
                     dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.ForeColor     = Color.DarkRed;
                     dcDiffLiability = dcTotalAsset - dcTotalLiability;
                 }
                 else
                 {
                     //--------------- Asset exceeds so in liability side ----------------//
                     dgvReport.Rows.Add();
                     dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value = "Difference";
                     dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value     = Math.Round((dcTotalLiability - dcTotalAsset), inDecimalPlaces);;
                     dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font      = newFont;
                     dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.DarkRed;
                     dcDiffAsset = dcTotalLiability - dcTotalAsset;
                 }
             }
             dgvReport.Rows.Add();
             dgvReport.Rows.Add();
             dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value = "__________________________";
             dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value = "__________________________";
             dgvReport.Rows.Add();
             dgvReport.Rows[dgvReport.Rows.Count - 1].DefaultCellStyle.Font          = newFont;
             dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtLiability"].Value = "Total";
             dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["dgvtxtAsset"].Value     = "Total";
             dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount1"].Value         = Math.Round((dcTotalAsset + dcDiffAsset), inDecimalPlaces);
             dgvReport.Rows[dgvReport.Rows.Count - 1].Cells["Amount2"].Value         = Math.Round((dcTotalLiability + dcDiffLiability), inDecimalPlaces);
             if (dgvReport.Columns.Count > 0)
             {
                 dgvReport.Columns["Amount1"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                 dgvReport.Columns["Amount2"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
             }
             decPrintOrNot  = dcTotalAsset + dcDiffAsset;
             decPrintOrNot1 = dcTotalLiability + dcDiffLiability;
             if (inCurrenRowIndex >= 0 && dgvReport.Rows.Count > 0 && inCurrenRowIndex < dgvReport.Rows.Count)
             {
                 if (dgvReport.Rows[inCurrenRowIndex].Cells[inCurentcolIndex].Visible)
                 {
                     dgvReport.CurrentCell = dgvReport.Rows[inCurrenRowIndex].Cells[inCurentcolIndex];
                 }
                 if (dgvReport.CurrentCell != null && dgvReport.CurrentCell.Visible)
                 {
                     dgvReport.CurrentCell.Selected = true;
                 }
             }
             inCurrenRowIndex = 0;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("BS :1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill Currency combobox
 /// </summary>
 public void CurrencyRateComboFill()
 {
     try
     {
         DataTable dtblCurrencyRate = new DataTable();
         CurrencySP spCurrency = new CurrencySP();
         dtblCurrencyRate = spCurrency.CurrencyViewAllForCombo();
         DataRow dr = dtblCurrencyRate.NewRow();
         dr[2] = "All";
         dtblCurrencyRate.Rows.InsertAt(dr, 0);
         cmbCurrencyRate.DataSource = dtblCurrencyRate;
         cmbCurrencyRate.ValueMember = "currencyId";
         cmbCurrencyRate.DisplayMember = "currencyName";
     }
     catch (Exception ex)
     {
         MessageBox.Show("ER6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #41
0
        /// <summary>
        /// Function to fill Datagridview
        /// </summary>
        public void GridFill()
        {
            try
            {
                if (!isFormLoad)
                {
                    DateValidation objValidation = new DateValidation();
                    objValidation.DateValidationFunction(txtFromDate);
                    if (txtFromDate.Text == string.Empty)
                    {
                        txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy");
                    }
                    objValidation.DateValidationFunction(txttoDate);
                    if (txttoDate.Text == string.Empty)
                    {
                        txttoDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy");
                    }
                    DateTime             strFromDate = DateTime.Parse(txtFromDate.Text.ToString());
                    DateTime             strTodate   = DateTime.Parse(txttoDate.Text.ToString());
                    FinancialStatementSP spFinancial = new FinancialStatementSP();
                    DataSet      dsetFinancial       = new DataSet();
                    SettingsInfo InfoSettings        = new SettingsInfo();
                    SettingsSP   SpSettings          = new SettingsSP();
                    dsetFinancial = spFinancial.CashFlow(strFromDate, strTodate);
                    DataTable    dtbl         = new DataTable();
                    Font         newFont      = new Font(dgvCashflow.Font, FontStyle.Bold);
                    CurrencyInfo InfoCurrency = new CurrencyInfo();
                    CurrencySP   SpCurrency   = new CurrencySP();
                    InfoCurrency = SpCurrency.CurrencyView(1);
                    int inDecimalPlaces = InfoCurrency.NoOfDecimalPlaces;
                    dgvCashflow.Rows.Clear();

                    for (int i = 0; i < 8; i++)
                    {
                        dtbl = dsetFinancial.Tables[i];
                        foreach (DataRow rw in dtbl.Rows)
                        {
                            dgvCashflow.Rows.Add();
                            dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtParticulars"].Value = rw["accountGroupName"].ToString();
                            dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtinflow"].Value      = rw["Balance"].ToString();
                            dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtID1"].Value         = rw["accountGroupId"].ToString();
                        }
                    }
                    //-------------------------------Calculating TotalInflow-----------------------------------------
                    decimal dcTotalInflow = 0m;
                    if (dtbl.Rows.Count > 0)
                    {
                        for (int i = 0; i < dgvCashflow.Rows.Count; i++)
                        {
                            decimal dcTotalIn = decimal.Parse(dgvCashflow.Rows[i].Cells["dgvtxtinflow"].Value.ToString());
                            dcTotalInflow += dcTotalIn;
                        }
                        dcTotInflow = dcTotalInflow;
                    }
                    //-----------------Outflow------------------------------
                    int index = 0;
                    for (int i = 8; i < 15; i++)
                    {
                        dtbl = new DataTable();
                        dtbl = dsetFinancial.Tables[i];
                        foreach (DataRow rw in dtbl.Rows)
                        {
                            if (index < dgvCashflow.Rows.Count)
                            {
                                dgvCashflow.Rows[index].Cells["dgvtxtParticulars1"].Value = rw["accountGroupName1"].ToString();
                                dgvCashflow.Rows[index].Cells["dgvtxtoutflow"].Value      = rw["Balance1"].ToString();
                                dgvCashflow.Rows[index].Cells["dgvtxtID2"].Value          = rw["accountGroupId"].ToString();
                            }
                            else
                            {
                                dgvCashflow.Rows.Add();
                                dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtParticulars1"].Value = rw["accountGroupName1"].ToString();
                                dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtoutflow"].Value      = rw["Balance1"].ToString();
                                dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtID2"].Value          = rw["accountGroupId"].ToString();
                            }
                            index++;
                        }
                    }
                    //-------------------------------Calculating TotalOutflow-----------------------------------------
                    decimal dcTotalOutflow = 0m;
                    if (dtbl.Rows.Count > 0)
                    {
                        for (int i = 0; i < dgvCashflow.Rows.Count - 1; i++)
                        {
                            decimal dcTotalIn = decimal.Parse(dgvCashflow.Rows[i].Cells["dgvtxtoutflow"].Value.ToString());
                            dcTotalOutflow += dcTotalIn;
                        }
                        dcTotOutflow = dcTotalOutflow;
                    }
                    dgvCashflow.Rows.Add();
                    dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtinflow"].Value  = "_______________________";
                    dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtoutflow"].Value = "_______________________";
                    dgvCashflow.Rows.Add();
                    dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].DefaultCellStyle.Font             = newFont;
                    dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtParticulars"].Value  = "Total";
                    dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtParticulars1"].Value = "Total";
                    dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtinflow"].Value       = Math.Round((dcTotalInflow), inDecimalPlaces);
                    dgvCashflow.Rows[dgvCashflow.Rows.Count - 1].Cells["dgvtxtoutflow"].Value      = Math.Round((dcTotalOutflow), inDecimalPlaces);
                    if (dgvCashflow.Columns.Count > 0)
                    {
                        dgvCashflow.Columns["dgvtxtinflow"].DefaultCellStyle.Alignment  = DataGridViewContentAlignment.MiddleRight;
                        dgvCashflow.Columns["dgvtxtoutflow"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                    }
                    if (inCurrenRowIndex >= 0 && dgvCashflow.Rows.Count > 0 && inCurrenRowIndex < dgvCashflow.Rows.Count)
                    {
                        if (dgvCashflow.Rows[inCurrenRowIndex].Cells[inCurentcolIndex].Visible)
                        {
                            dgvCashflow.CurrentCell = dgvCashflow.Rows[inCurrenRowIndex].Cells[inCurentcolIndex];
                        }
                        if (dgvCashflow.CurrentCell != null && dgvCashflow.CurrentCell.Visible)
                        {
                            dgvCashflow.CurrentCell.Selected = true;
                        }
                    }
                    inCurrenRowIndex = 0;
                }
            }
            catch (Exception ex)
            {
                formMDI.infoError.ErrorString = "CF1:" + ex.Message;
            }
        }
Exemple #42
0
 /// <summary>
 /// Functions to clear the form controls based on the settings
 /// </summary>
 public void ClearFunctions()
 {
     try
     {
         CurrencySP SPCurrency = new CurrencySP();
         SettingsSP spSettings = new SettingsSP();
         strCurrencySymbol = SPCurrency.CurrencyView(PublicVariables._decCurrencyId).CurrencySymbol;
         if (spSettings.SettingsStatusCheck("AllowGodown") == "Yes")
         {
             cmbGodown.Visible = true;
             lblGodown.Visible = true;
         }
         else
         {
             cmbGodown.Visible = false;
             lblGodown.Visible = false;
         }
         if (spSettings.SettingsStatusCheck("AllowRack") == "Yes")
         {
             cmbRack.Visible = true;
             lblRack.Visible = true;
         }
         else
         {
             cmbRack.Visible = false;
             lblRack.Visible = false;
         }
         if (spSettings.SettingsStatusCheck("AllowBatch") == "Yes")
         {
             cmbBatch.Visible = true;
             lblBatch.Visible = true;
         }
         else
         {
             cmbBatch.Visible = false;
             lblBatch.Visible = false;
         }
         if (spSettings.SettingsStatusCheck("ShowProductCode") == "Yes")
         {
             lblProductcode.Visible = true;
             txtProductCode.Visible = true;
             dgvPointOfSales.Columns["dgvtxtProductCode"].Visible = true;
         }
         else
         {
             lblProductcode.Visible = false;
             txtProductCode.Visible = false;
             dgvPointOfSales.Columns["dgvtxtProductCode"].Visible = false;
         }
         if (spSettings.SettingsStatusCheck("Barcode") == "Yes")
         {
             lblBarcode.Visible = true;
             txtBarcode.Visible = true;
         }
         else
         {
             lblBarcode.Visible = false;
             txtBarcode.Visible = false;
         }
         if (spSettings.SettingsStatusCheck("ShowDiscountAmount") == "Yes")
         {
             txtDiscountAmount.Visible = true;
             lblDiscountAmt.Visible = true;
             dgvPointOfSales.Columns["dgvtxtDiscount"].Visible = true;
         }
         else
         {
             txtDiscountAmount.Visible = false;
             lblDiscountAmt.Visible = false;
             dgvPointOfSales.Columns["dgvtxtDiscount"].Visible = false;
         }
         if (spSettings.SettingsStatusCheck("ShowDiscountPercentage") == "Yes")
         {
             txtDiscountPercentage.Visible = true;
             lblDiscountPercentage.Visible = true;
         }
         else
         {
             txtDiscountPercentage.Visible = false;
             lblDiscountPercentage.Visible = false;
         }
         if (spSettings.SettingsStatusCheck("ShowUnit") == "Yes")
         {
             cmbUnit.Visible = true;
             lblUnit.Visible = true;
             dgvPointOfSales.Columns["dgvtxtUnit"].Visible = true;
         }
         else
         {
             cmbUnit.Visible = false;
             lblUnit.Visible = false;
             dgvPointOfSales.Columns["dgvtxtUnit"].Visible = false;
         }
         if (spSettings.SettingsStatusCheck("Tax") == "Yes")
         {
             cmbTax.Visible = true;
             lblTax.Visible = true;
             txtTaxAmount.Visible = true;
             lblTaxAmount.Visible = true;
             lblTaxTotalAmount.Visible = true;
             lblLedgerTotal.Visible = true;
             dgvPointOfSales.Columns["dgvtxtTaxPercentage"].Visible = true;
             dgvPointOfSales.Columns["dgvtxtTaxAmount"].Visible = true;
             dgvPOSTax.Visible = true;
         }
         else
         {
             cmbTax.Visible = false;
             lblTax.Visible = false;
             txtTaxAmount.Visible = false;
             lblTaxAmount.Visible = false;
             lblTaxTotalAmount.Visible = false;
             lblLedgerTotal.Visible = false;
             dgvPointOfSales.Columns["dgvtxtTaxPercentage"].Visible = false;
             dgvPointOfSales.Columns["dgvtxtTaxAmount"].Visible = false;
             dgvPOSTax.Visible = false;
         }
         if (PrintAfetrSave())
         {
             cbxPrintAfterSave.Checked = true;
         }
         else
         {
             cbxPrintAfterSave.Checked = false;
         }
         dtpDate.Value = PublicVariables._dtCurrentDate;
         dtpDate.MinDate = PublicVariables._dtFromDate;
         dtpDate.MaxDate = PublicVariables._dtToDate;
         dtpDate.CustomFormat = "dd-MMMM-yyyy";
         CashorPartyComboFill();
         PricingLevelComboFill();
         salesManComboFill();
         SalesAccountComboFill();
         CounterComboFill();
         ItemComboFill();
         taxGridFill();
         cmbTaxComboFill();
         if (isAutomatic)
         {
             VoucherNumberGeneration();
         }
         Clear();
     }
     catch (Exception ex)
     {
         MessageBox.Show("POS : 02" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }