/// <summary>
 /// Currency Combofill Function
 /// </summary>
 public void CurrencyComboFill()
 {
     try
     {
         DataTable dtblCurrency = new DataTable();
         SettingsSP spSettings = new SettingsSP();
         dtblCurrency = TransactionGeneralFillObj.CurrencyComboByDate(Convert.ToDateTime(txtDate.Text));
         cmbCurrency.DataSource = dtblCurrency;
         cmbCurrency.DisplayMember = "currencyName";
         cmbCurrency.ValueMember = "exchangeRateId";
         cmbCurrency.SelectedValue = 1m;
         if (spSettings.SettingsStatusCheck("MultiCurrency") == "Yes")
         {
             cmbCurrency.Enabled = true;
         }
         else
         {
             cmbCurrency.Enabled = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PO1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #2
0
 /// <summary>
 /// Function to set the calculation method by checking the settings
 /// </summary>
 public void CalculationMethod()
 {
     try
     {
         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";
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "AGR6:" + ex.Message;
     }
 }
 /// <summary>
 /// Function to set the calculation method by checking the settings
 /// </summary>
 public void CalculationMethod()
 {
     try
     {
         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";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("AGR:6" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #4
0
        /// <summary>
        /// Function to print StockJournal in curresponding Crystal report
        /// </summary>
        /// <param name="dsStockJournal"></param>
        internal void StockJournalPrinting(DataSet dsStockJournal)
        {
            try
            {

                crptStockJournal crptStockJournalObj = new crptStockJournal();
                foreach (DataTable dtbl in dsStockJournal.Tables)
                {
                    if (dtbl.TableName == "Table")
                    {
                        crptStockJournalObj.Database.Tables["dtblCompany"].SetDataSource(dtbl);
                    }
                    else if (dtbl.TableName == "Table1")
                    {

                        crptStockJournalObj.Database.Tables["dtblStockJournalMaster"].SetDataSource(dtbl);

                    }
                    else if (dtbl.TableName == "Table2")
                    {
                        crptStockJournalObj.Database.Tables["dtblStockJournalDetailsConsumption"].SetDataSource(dtbl);

                    }
                    else if (dtbl.TableName == "Table3")
                    {
                        crptStockJournalObj.Database.Tables["dtblStockJournalDetailsProduction"].SetDataSource(dtbl);
                    }

                }
                this.crptViewer.ReportSource = crptStockJournalObj;
                SettingsSP spSettings = new SettingsSP();

                if (spSettings.SettingsStatusCheck("DirectPrint") == "No")
                {
                    base.Show();
                    this.BringToFront();
                }
                else
                {
                    crptStockJournalObj.PrintToPrinter(1, false, 0, 0);
                }
            }

            catch (Exception)
            {
                throw;
            }
        }
Exemple #5
0
 /// <summary>
 /// Function to check the references in each one
 /// </summary>
 public void Checkreference()
 {
     try
     {
         SettingsSP SpSettings = new SettingsSP();
         DataTable dtbl = new DataTable();
         dtbl = SpSettings.SettinsCheckReference();
         if (bool.Parse(dtbl.Rows[0]["CurrencyExist"].ToString()) == true)
         {
             cbxMultiCurrency.Enabled = false;
         }
         else
         {
             cbxMultiCurrency.Enabled = true;
         }
         if (bool.Parse(dtbl.Rows[0]["Godown"].ToString()) == true)
         {
             cbxAllowGodown.Enabled = false;
         }
         else
         {
             cbxAllowGodown.Enabled = true;
         }
         if (bool.Parse(dtbl.Rows[0]["Rack"].ToString()) == true)
         {
             cbxAllowRack.Enabled = false;
         }
         else
         {
             cbxAllowRack.Enabled = true;
         }
         if (bool.Parse(dtbl.Rows[0]["BillByBillExist"].ToString()) == true)
         {
             cbxBillByBill.Enabled = false;
         }
         else
         {
             cbxBillByBill.Enabled = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("ST1: " + 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;
 }
 /// <summary>
 /// Function to fill Unit combobox
 /// </summary>
 public void UnitComboFill()
 {
     try
     {
         dtbl = TransactionsGeneralFill.UnitViewAll(cmbUnit, false);
         SettingsSP spSettings = new SettingsSP();
         if (spSettings.SettingsStatusCheck("ShowUnit") == "Yes")
         {
             cmbUnit.Enabled = true;
         }
         else
         {
             cmbUnit.Enabled = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("MPC1:" + 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>
        /// Printing checkbox status checking
        /// </summary>
        public void PrintCheck()
        {
            try
            {
                SettingsSP spSettings = new SettingsSP();

                if (spSettings.SettingsStatusCheck("TickPrintAfterSave") == "Yes")
                {
                    cbxPrintafterSave.Checked = true;
                }
                else
                {
                    cbxPrintafterSave.Checked = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PV2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Currency Combofill function
        /// </summary>
        public void GridCurrencyComboFill()
        {
            try
            {
                DataTable dtbl = new DataTable();
                TransactionsGeneralFill Obj = new TransactionsGeneralFill();
                dtbl = Obj.CurrencyComboByDate(Convert.ToDateTime(txtDate.Text));
                DataRow dr = dtbl.NewRow();
                dr["exchangeRateId"] = "0";
                dr["currencyName"] = string.Empty;
                dtbl.Rows.InsertAt(dr, 0);
                dgvcmbCurrency.DataSource = dtbl;
                dgvcmbCurrency.DisplayMember = "currencyName";
                dgvcmbCurrency.ValueMember = "exchangeRateId";
                SettingsSP spSettings = new SettingsSP();
                if (spSettings.SettingsStatusCheck("MultiCurrency") == "Yes")
                {
                    dgvcmbCurrency.ReadOnly = false;
                }
                else
                {
                    dgvcmbCurrency.ReadOnly = true;

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PV5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to call the SaveOrEditFunction after checking negative balance 
        /// </summary>
        public void SaveOrEdit()
        {
            try
            {
                if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, this.Name, btnSave.Text))
                {
                    JournalMasterSP spJournalMaster = new JournalMasterSP();
                    //=====================================================
                    SettingsSP spSettings = new SettingsSP();
                    string strStatus = spSettings.SettingsStatusCheck("NegativeCashTransaction");
                    decimal decBalance = 0;
                    decimal decCalcAmount = 0;
                    AccountLedgerSP spAccountLedger = new AccountLedgerSP();
                    bool isNegativeLedger = false;
                    int inRowCount = dgvJournalVoucher.RowCount;
                    for (int i = 0; i < inRowCount - 1; i++)
                    {
                        decimal decledgerId = 0;
                        if (dgvJournalVoucher.Rows[i].Cells["dgvcmbAccountLedger"].Value != null && dgvJournalVoucher.Rows[i].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
                        {
                            decledgerId = Convert.ToDecimal(dgvJournalVoucher.Rows[i].Cells["dgvcmbAccountLedger"].Value.ToString());

                            decBalance = spAccountLedger.CheckLedgerBalance(decledgerId);
                            if (dgvJournalVoucher.Rows[i].Cells["dgvtxtAmount"].Value != null && dgvJournalVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString() != string.Empty)
                            {
                                decCalcAmount = decBalance - Convert.ToDecimal(dgvJournalVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString());
                            }
                            if (decCalcAmount < 0)
                            {
                                isNegativeLedger = true;
                                break;
                            }
                        }
                    }
                    //=========================================
                    if (isNegativeLedger)
                    {

                        if (strStatus == "Warn")
                        {
                            if (MessageBox.Show("Negative balance exists,Do you want to Continue", "Open miracle", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                            {
                                SaveOrEditFunction();
                            }
                        }
                        else if (strStatus == "Block")
                        {
                            MessageBox.Show("Cannot continue ,due to negative balance", "Open miracle", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        }
                        else
                        {
                            SaveOrEditFunction();
                        }
                    }
                    else
                    {
                        SaveOrEditFunction();
                    }

                }
                else
                {
                    Messages.NoPrivillageMessage();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("JV18:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 ///  Save function
 /// </summary>
 public void SaveFunction()
 {
     SalesMasterSP spSalesMaster = new SalesMasterSP();
     SalesDetailsSP spSalesDetails = new SalesDetailsSP();
     StockPostingInfo infoStockPosting = new StockPostingInfo();
     SalesMasterInfo InfoSalesMaster = new SalesMasterInfo();
     SalesDetailsInfo InfoSalesDetails = new SalesDetailsInfo();
     StockPostingSP spStockPosting = new StockPostingSP();
     AdditionalCostInfo infoAdditionalCost = new AdditionalCostInfo();
     AdditionalCostSP spAdditionalCost = new AdditionalCostSP();
     SalesBillTaxInfo infoSalesBillTax = new SalesBillTaxInfo();
     SalesBillTaxSP spSalesBillTax = new SalesBillTaxSP();
     UnitConvertionSP SPUnitConversion = new UnitConvertionSP();
     try
     {
         InfoSalesMaster.AdditionalCost = Convert.ToDecimal(lblLedgerTotalAmount.Text);
         InfoSalesMaster.BillDiscount = Convert.ToDecimal(txtBillDiscount.Text.Trim());
         InfoSalesMaster.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text.Trim().ToString());
         InfoSalesMaster.CustomerName = txtCustomer.Text.Trim();
         InfoSalesMaster.Date = Convert.ToDateTime(txtDate.Text.ToString());
         InfoSalesMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
         InfoSalesMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString());
         InfoSalesMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
         InfoSalesMaster.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text.Trim());
         InfoSalesMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
         InfoSalesMaster.VoucherTypeId = DecSalesInvoiceVoucherTypeId;
         if (isAutomatic)
         {
             InfoSalesMaster.InvoiceNo = txtInvoiceNo.Text.Trim();
             InfoSalesMaster.VoucherNo = strVoucherNo;
             InfoSalesMaster.SuffixPrefixId = decSalseInvoiceSuffixPrefixId;
         }
         else
         {
             InfoSalesMaster.InvoiceNo = txtInvoiceNo.Text.Trim();
             InfoSalesMaster.VoucherNo = strVoucherNo;
             InfoSalesMaster.SuffixPrefixId = 0;
         }
         if (cmbSalesMode.Text == "Against SalesOrder")
         {
             InfoSalesMaster.OrderMasterId = Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString());
         }
         else
         {
             InfoSalesMaster.OrderMasterId = 0;
         }
         if (cmbSalesMode.Text == "Against Delivery Note")
         {
             InfoSalesMaster.DeliveryNoteMasterId = Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString());
         }
         else
         {
             InfoSalesMaster.DeliveryNoteMasterId = 0;
         }
         if (cmbSalesMode.Text == "Against Quotation")
         {
             InfoSalesMaster.QuotationMasterId = Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString());
         }
         else
         {
             InfoSalesMaster.QuotationMasterId = 0;
         }
         InfoSalesMaster.Narration = txtNarration.Text.Trim();
         InfoSalesMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString());
         InfoSalesMaster.SalesAccount = Convert.ToDecimal(cmbSalesAccount.SelectedValue.ToString());
         InfoSalesMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text.Trim());
         if (dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible)
         {
             InfoSalesMaster.TaxAmount = Convert.ToDecimal(lblTaxTotalAmount.Text.Trim());
         }
         else
         {
             InfoSalesMaster.TaxAmount = 0;
         }
         InfoSalesMaster.UserId = PublicVariables._decCurrentUserId;
         InfoSalesMaster.LrNo = txtVehicleNo.Text;
         InfoSalesMaster.TransportationCompany = txtTransportCompany.Text.Trim();
         InfoSalesMaster.POS = false;
         InfoSalesMaster.CounterId = 0;
         InfoSalesMaster.ExtraDate = DateTime.Now;
         InfoSalesMaster.Extra1 = string.Empty;
         InfoSalesMaster.Extra2 = string.Empty;
         decimal decSalesMasterId = spSalesMaster.SalesMasterAdd(InfoSalesMaster);
         int inRowCount = dgvSalesInvoice.RowCount;
         InfoSalesDetails.SalesMasterId = decSalesMasterId;
         InfoSalesDetails.ExtraDate = DateTime.Now;
         InfoSalesDetails.Extra1 = string.Empty;
         InfoSalesDetails.Extra2 = string.Empty;
         string strAgainstInvoiceN0 = txtInvoiceNo.Text.Trim();
         for (int inI = 0; inI < inRowCount - 1; inI++)
         {
             if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductName"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductName"].Value.ToString() != string.Empty)
             {
                 if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQty"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQty"].Value.ToString() != string.Empty)
                 {
                     if (cmbSalesMode.Text == "Against SalesOrder")
                     {
                         InfoSalesDetails.OrderDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSISalesOrderDetailsId"].Value.ToString());
                     }
                     else
                     {
                         InfoSalesDetails.OrderDetailsId = 0;
                     }
                     if (cmbSalesMode.Text == "Against Delivery Note")
                     {
                         InfoSalesDetails.DeliveryNoteDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value.ToString());
                     }
                     else
                     {
                         InfoSalesDetails.DeliveryNoteDetailsId = 0;
                     }
                     if (cmbSalesMode.Text == "Against Quotation")
                     {
                         InfoSalesDetails.QuotationDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQuotationDetailsId"].Value.ToString());
                     }
                     else
                     {
                         InfoSalesDetails.QuotationDetailsId = 0;
                     }
                     InfoSalesDetails.SlNo = Convert.ToInt32(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceSlno"].Value.ToString());
                     InfoSalesDetails.ProductId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductId"].Value.ToString());
                     InfoSalesDetails.Qty = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQty"].Value.ToString());
                     InfoSalesDetails.Rate = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceRate"].Value.ToString());
                     InfoSalesDetails.UnitId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoicembUnitName"].Value.ToString());
                     InfoSalesDetails.UnitConversionId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceUnitConversionId"].Value.ToString());
                     InfoSalesDetails.Discount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDiscountAmount"].Value.ToString());
                     InfoSalesDetails.BatchId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceBatch"].Value.ToString());
                     if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString() != string.Empty)
                     {
                         InfoSalesDetails.GodownId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString());
                     }
                     else
                     {
                         InfoSalesDetails.GodownId = 0;
                     }
                     if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString() != string.Empty)
                     {
                         InfoSalesDetails.RackId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString());
                     }
                     else
                     {
                         InfoSalesDetails.RackId = 0;
                     }
                     if (dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible)
                     {
                         InfoSalesDetails.TaxId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceTaxName"].Value.ToString());
                         InfoSalesDetails.TaxAmount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceTaxAmount"].Value.ToString());
                     }
                     else
                     {
                         InfoSalesDetails.TaxId = 1;
                         InfoSalesDetails.TaxAmount = 0;
                     }
                     InfoSalesDetails.GrossAmount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceGrossValue"].Value.ToString());
                     InfoSalesDetails.NetAmount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceNetAmount"].Value.ToString());
                     InfoSalesDetails.Amount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceAmount"].Value.ToString());
                     spSalesDetails.SalesDetailsAdd(InfoSalesDetails);
                     infoStockPosting.Date = Convert.ToDateTime(txtDate.Text.Trim().ToString());
                     infoStockPosting.ProductId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductId"].Value.ToString());
                     infoStockPosting.BatchId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceBatch"].Value.ToString());
                     infoStockPosting.UnitId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoicembUnitName"].Value.ToString());
                     if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString() != string.Empty)
                     {
                         infoStockPosting.GodownId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString());
                     }
                     else
                     {
                         infoStockPosting.GodownId = 0;
                     }
                     if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString() != string.Empty)
                     {
                         infoStockPosting.RackId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString());
                     }
                     else
                     {
                         infoStockPosting.RackId = 0;
                     }
                     infoStockPosting.Rate = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceRate"].Value.ToString());
                     infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                     infoStockPosting.ExtraDate = DateTime.Now;
                     infoStockPosting.Extra1 = string.Empty;
                     infoStockPosting.Extra2 = string.Empty;
                     if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value != null)
                     {
                         if (Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value.ToString()) != 0)
                         {
                             infoStockPosting.InwardQty = InfoSalesDetails.Qty / SPUnitConversion.UnitConversionRateByUnitConversionId(InfoSalesDetails.UnitConversionId);
                             infoStockPosting.OutwardQty = 0;
                             infoStockPosting.VoucherNo = strVoucherNoTostockPost;
                             infoStockPosting.AgainstVoucherNo = strVoucherNo;
                             infoStockPosting.InvoiceNo = strInvoiceNoTostockPost;
                             infoStockPosting.AgainstInvoiceNo = strAgainstInvoiceN0;
                             infoStockPosting.VoucherTypeId = decVouchertypeIdTostockPost;
                             infoStockPosting.AgainstVoucherTypeId = DecSalesInvoiceVoucherTypeId;
                             spStockPosting.StockPostingAdd(infoStockPosting);
                         }
                     }
                     infoStockPosting.InwardQty = 0;
                     infoStockPosting.OutwardQty = InfoSalesDetails.Qty / SPUnitConversion.UnitConversionRateByUnitConversionId(InfoSalesDetails.UnitConversionId);
                     infoStockPosting.VoucherNo = InfoSalesMaster.VoucherNo; ;
                     infoStockPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId;
                     infoStockPosting.InvoiceNo = InfoSalesMaster.InvoiceNo;
                     infoStockPosting.AgainstInvoiceNo = "NA";
                     infoStockPosting.AgainstVoucherNo = "NA";
                     infoStockPosting.AgainstVoucherTypeId = 0;
                     infoStockPosting.Extra1 = string.Empty;
                     infoStockPosting.Extra2 = string.Empty;
                     spStockPosting.StockPostingAdd(infoStockPosting);
                 }
             }
         }
         if (dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible)
         {
             int inTaxRowCount = dgvSalesInvoiceTax.RowCount;
             infoSalesBillTax.SalesMasterId = decSalesMasterId;
             infoSalesBillTax.ExtraDate = DateTime.Now;
             infoSalesBillTax.Extra1 = string.Empty;
             infoSalesBillTax.Extra2 = string.Empty;
             for (int inI = 0; inI < inTaxRowCount; inI++)
             {
                 if (dgvSalesInvoiceTax.Rows[inI].Cells["dgvtxtTtaxId"].Value != null && dgvSalesInvoiceTax.Rows[inI].Cells["dgvtxtTtaxId"].Value.ToString() != string.Empty)
                 {
                     if (dgvSalesInvoiceTax.Rows[inI].Cells["dgvtxtTtaxAmount"].Value != null && dgvSalesInvoiceTax.Rows[inI].Cells["dgvtxtTtaxAmount"].Value.ToString() != string.Empty)
                     {
                         decimal decAmount = Convert.ToDecimal(dgvSalesInvoiceTax.Rows[inI].Cells["dgvtxtTtaxAmount"].Value);
                         if (decAmount > 0)
                         {
                             infoSalesBillTax.TaxId = Convert.ToInt32(dgvSalesInvoiceTax.Rows[inI].Cells["dgvtxtTtaxId"].Value.ToString());
                             infoSalesBillTax.TaxAmount = Convert.ToDecimal(dgvSalesInvoiceTax.Rows[inI].Cells["dgvtxtTtaxAmount"].Value.ToString());
                             spSalesBillTax.SalesBillTaxAdd(infoSalesBillTax);
                         }
                     }
                 }
             }
         }
         int inAddRowCount = dgvSalesInvoiceLedger.RowCount;
         infoAdditionalCost.VoucherTypeId = DecSalesInvoiceVoucherTypeId;
         infoAdditionalCost.VoucherNo = strVoucherNo;
         infoAdditionalCost.ExtraDate = DateTime.Now;
         infoAdditionalCost.Extra1 = string.Empty;
         infoAdditionalCost.Extra2 = string.Empty;
         for (int inI = 0; inI < inAddRowCount; inI++)
         {
             if (dgvSalesInvoiceLedger.Rows[inI].Cells["dgvCmbAdditionalCostledgerName"].Value != null && dgvSalesInvoiceLedger.Rows[inI].Cells["dgvCmbAdditionalCostledgerName"].Value.ToString() != string.Empty)
             {
                 if (dgvSalesInvoiceLedger.Rows[inI].Cells["dgvtxtAdditionalCoastledgerAmount"].Value != null && dgvSalesInvoiceLedger.Rows[inI].Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString() != string.Empty)
                 {
                     infoAdditionalCost.LedgerId = Convert.ToInt32(dgvSalesInvoiceLedger.Rows[inI].Cells["dgvCmbAdditionalCostledgerName"].Value.ToString());
                     if (!cmbCashOrbank.Visible)
                     {
                         infoAdditionalCost.Debit = 0;
                         infoAdditionalCost.Credit = Convert.ToDecimal(dgvSalesInvoiceLedger.Rows[inI].Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString());
                     }
                     else
                     {
                         infoAdditionalCost.Debit = Convert.ToDecimal(dgvSalesInvoiceLedger.Rows[inI].Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString());
                         infoAdditionalCost.Credit = 0;
                     }
                     spAdditionalCost.AdditionalCostAdd(infoAdditionalCost);
                 }
             }
         }
         if (!cmbCashOrbank.Visible)
         {
             decimal decCAshOrBankId = 0;
             decCAshOrBankId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
             decimal decTotalAddAmount = Convert.ToDecimal(lblLedgerTotalAmount.Text.Trim().ToString());
             if (decTotalAddAmount > 0)
             {
                 infoAdditionalCost.Debit = decTotalAddAmount;
                 infoAdditionalCost.Credit = 0;
                 infoAdditionalCost.LedgerId = decCAshOrBankId;
                 infoAdditionalCost.VoucherTypeId = DecSalesInvoiceVoucherTypeId;
                 infoAdditionalCost.VoucherNo = strVoucherNo;
                 infoAdditionalCost.ExtraDate = DateTime.Now;
                 infoAdditionalCost.Extra1 = string.Empty;
                 infoAdditionalCost.Extra2 = string.Empty;
                 spAdditionalCost.AdditionalCostAdd(infoAdditionalCost);
             }
         }
         else
         {
             if (cmbCashOrbank.Visible)
             {
                 decimal decCAshOrBankId = 0;
                 decCAshOrBankId = Convert.ToDecimal(cmbCashOrbank.SelectedValue.ToString());
                 decimal decTotalAddAmount = Convert.ToDecimal(lblLedgerTotalAmount.Text.Trim().ToString());
                 if (decTotalAddAmount > 0)
                 {
                     infoAdditionalCost.Debit = 0;
                     infoAdditionalCost.Credit = decTotalAddAmount;
                     infoAdditionalCost.LedgerId = decCAshOrBankId;
                     infoAdditionalCost.VoucherTypeId = DecSalesInvoiceVoucherTypeId;
                     infoAdditionalCost.VoucherNo = strVoucherNo;
                     infoAdditionalCost.ExtraDate = DateTime.Now;
                     infoAdditionalCost.Extra1 = string.Empty;
                     infoAdditionalCost.Extra2 = string.Empty;
                     spAdditionalCost.AdditionalCostAdd(infoAdditionalCost);
                 }
             }
         }
         ledgerPostingAdd();
         if (spSalesMaster.SalesInvoiceInvoicePartyCheckEnableBillByBillOrNot(Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString())))
         {
             partyBalanceAdd();
         }
         Messages.SavedMessage();
         if (cbxPrintAfterSave.Checked == true)
         {
             SettingsSP spSettings = new SettingsSP();
             if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
             {
                 PrintForDotMatrix(decSalesMasterId);
             }
             else
             {
                 Print(decSalesMasterId);
             }
         }
         Clear();
     }
     catch (Exception ex)
     {
         MessageBox.Show("SI: 70" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #13
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;
            }
        }
        /// <summary>
        /// Function to fill currency combobox
        /// </summary>
        public void CurrencyComboFill()
        {
            SettingsSP spSettings = new SettingsSP();
            TransactionsGeneralFill TransactionGeneralFillObj = new TransactionsGeneralFill();
            DataTable dtbl = new DataTable();
            try
            {
                dtbl = TransactionGeneralFillObj.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;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("SJ:51" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #15
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 #16
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);
            }
        }
Exemple #17
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
                {
                }
            }
        }
        /// <summary>
        /// Function to check settings for stock journal
        /// </summary>
        public void StockJournalSettingsCheck()
        {
            try
            {
                SettingsSP spSettings = new SettingsSP();
                if (spSettings.SettingsStatusCheck("AllowGodown") == "Yes")
                {
                    rbtnTransfer.Enabled = true;
                    dgvConsumption.Columns["dgvcmbConsumptionGodown"].Visible = true;
                    dgvProduction.Columns["dgvcmbProductionGodown"].Visible = true;
                }
                else
                {
                    rbtnTransfer.Enabled = false;
                    dgvConsumption.Columns["dgvcmbConsumptionGodown"].Visible = false;
                    dgvProduction.Columns["dgvcmbProductionGodown"].Visible = false;
                }
                if (spSettings.SettingsStatusCheck("AllowRack") == "Yes")
                {
                    dgvConsumption.Columns["dgvcmbConsumptionRack"].Visible = true;
                    dgvProduction.Columns["dgvcmbProductionRack"].Visible = true;
                }
                else
                {
                    dgvConsumption.Columns["dgvcmbConsumptionRack"].Visible = false;
                    dgvProduction.Columns["dgvcmbProductionRack"].Visible = false;
                }

                if (spSettings.SettingsStatusCheck("ShowUnit") == "Yes")
                {
                    dgvConsumption.Columns["dgvcmbConsumptionunitId"].Visible = true;
                    dgvProduction.Columns["dgvcmbProductionunitId"].Visible = true;
                }
                else
                {
                    dgvConsumption.Columns["dgvcmbConsumptionunitId"].Visible = false;
                    dgvProduction.Columns["dgvcmbProductionunitId"].Visible = false;
                }
                if (spSettings.SettingsStatusCheck("ShowProductCode") == "Yes")
                {
                    dgvConsumption.Columns["dgvtxtConsumptionProductCode"].Visible = true;
                    dgvProduction.Columns["dgvtxtProductionProductCode"].Visible = true;
                }
                else
                {
                    dgvConsumption.Columns["dgvtxtConsumptionProductCode"].Visible = false;
                    dgvProduction.Columns["dgvtxtProductionProductCode"].Visible = false;
                }

                if (spSettings.SettingsStatusCheck("Barcode") == "Yes")
                {
                    dgvConsumption.Columns["dgvtxtConsumptionBarcode"].Visible = true;
                    dgvProduction.Columns["dgvtxtProductionBarcode"].Visible = true;
                }
                else
                {
                    dgvConsumption.Columns["dgvtxtConsumptionBarcode"].Visible = false;
                    dgvProduction.Columns["dgvtxtProductionBarcode"].Visible = false;
                }
                if (spSettings.SettingsStatusCheck("AllowBatch") == "Yes")
                {
                    dgvConsumption.Columns["dgvcmbConsumptionBatch"].Visible = true;
                    dgvProduction.Columns["dgvcmbProductionBatch"].Visible = true;
                }
                else
                {
                    dgvConsumption.Columns["dgvcmbConsumptionBatch"].Visible = false;
                    dgvProduction.Columns["dgvcmbProductionBatch"].Visible = false;

                }
                if (spSettings.SettingsStatusCheck("MultiCurrency") == "Yes")
                {
                    cmbCurrency.Enabled = true;
                }
                else
                {
                    cmbCurrency.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("SJ:4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// To check the status of the product
        /// </summary>
        public void QuantityStatusCheck()
        {
            try
            {

                int inRowConsumption = dgvConsumption.RowCount;
                int inRowProduction = dgvProduction.RowCount;
                if (rbtnTransfer.Checked == true)
                {
                    if (inRowConsumption - 1 == 0)
                    {
                        Messages.InformationMessage("Can't save Stock Journal without atleast one product with complete details");
                        dgvConsumption.Focus();
                        goto Exit;
                    }
                    if (inRowProduction - 1 == 0)
                    {
                        Messages.InformationMessage("Can't save Stock Journal without atleast one product with complete details");
                        dgvProduction.Focus();
                        goto Exit;
                    }
                }
                decimal decProductId = 0;
                decimal decBatchId = 0;
                decimal decCalcQty = 0;
                StockPostingSP spStockPosting = new StockPostingSP();
                SettingsSP spSettings = new SettingsSP();
                string strStatus = spSettings.SettingsStatusCheck("NegativeStockStatus");
                bool isNegativeLedger = false;
                int inRowCount = dgvConsumption.RowCount;
                for (int i = 0; i < inRowCount - 1; i++)
                {
                    if (dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductId"].Value != null && dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductId"].Value.ToString() != string.Empty)
                    {
                        decProductId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductId"].Value.ToString());
                        if (dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value != null && dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value.ToString() != string.Empty)
                        {
                            decBatchId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value.ToString());
                        }
                        decimal decCurrentStock = spStockPosting.StockCheckForProductSale(decProductId, decBatchId);
                        if (dgvConsumption.Rows[i].Cells["dgvtxtConsumptionQty"].Value != null && dgvConsumption.Rows[i].Cells["dgvtxtConsumptionQty"].Value.ToString() != string.Empty)
                        {
                            decCalcQty = decCurrentStock - Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionQty"].Value.ToString());
                        }
                        if (decCalcQty < 0)
                        {
                            isNegativeLedger = true;
                            break;
                        }
                    }
                }
                if (isNegativeLedger)
                {
                    if (strStatus == "Warn")
                    {
                        if (MessageBox.Show("Negative Stock balance exists,Do you want to Continue", "Open miracle", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                        {
                            SaveOrEdit();
                        }
                    }
                    else if (strStatus == "Block")
                    {
                        MessageBox.Show("Cannot continue ,due to negative stock balance", "Open miracle", MessageBoxButtons.OK, MessageBoxIcon.Stop);

                    }
                    else
                    {
                        SaveOrEdit();
                    }
                }
                else
                {
                    SaveOrEdit();
                }
            Exit: ;
            }

            catch (Exception ex)
            {
                MessageBox.Show("SJ:39" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Checking the Settings of TickPrintAfterSave checkBox
 /// </summary>
 public void PrintCheck()
 {
     try
     {
         SettingsSP spSettings = new SettingsSP();
         cbxPrint.Checked = new SettingsSP().SettingsStatusCheck("TickPrintAfterSave") == "Yes" ? true : false;
     }
     catch (Exception ex)
     {
         MessageBox.Show("DN08: " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #21
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;
     }
 }
 /// <summary>
 /// Checking the settings and arrange the form controlls based on settings
 /// </summary>
 public void SalesInvoiceSettingsCheck()
 {
     SettingsSP spSettings = new SettingsSP();
     try
     {
         cmbCashOrbank.Visible = false;
         lblcashOrBank.Visible = false;
         if (spSettings.SettingsStatusCheck("AllowGodown") == "Yes")
         {
             dgvSalesInvoice.Columns["dgvcmbSalesInvoiceGodown"].Visible = true;
         }
         else
         {
             dgvSalesInvoice.Columns["dgvcmbSalesInvoiceGodown"].Visible = false;
         }
         if (spSettings.SettingsStatusCheck("AllowRack") == "Yes")
         {
             dgvSalesInvoice.Columns["dgvcmbSalesInvoiceRack"].Visible = true;
         }
         else
         {
             dgvSalesInvoice.Columns["dgvcmbSalesInvoiceRack"].Visible = false;
         }
         if (spSettings.SettingsStatusCheck("ShowBrand") == "Yes")
         {
             dgvSalesInvoice.Columns["dgvtxtSalesInvoiceBrand"].Visible = true;
         }
         else
         {
             dgvSalesInvoice.Columns["dgvtxtSalesInvoiceBrand"].Visible = false;
         }
         if (spSettings.SettingsStatusCheck("ShowSalesRate") == "yes")
         {
             dgvSalesInvoice.Columns["dgvtxtSalesInvoiceSalesRate"].Visible = true;
         }
         else
         {
             dgvSalesInvoice.Columns["dgvtxtSalesInvoiceSalesRate"].Visible = false;
         }
         if (spSettings.SettingsStatusCheck("ShowMRP") == "Yes")
         {
             dgvSalesInvoice.Columns["dgvtxtSalesInvoiceMrp"].Visible = true;
         }
         else
         {
             dgvSalesInvoice.Columns["dgvtxtSalesInvoiceMrp"].Visible = false;
         }
         if (spSettings.SettingsStatusCheck("MultiCurrency") == "Yes")
         {
             cmbCurrency.Enabled = true;
         }
         else
         {
             cmbCurrency.Enabled = false;
         }
         if (spSettings.SettingsStatusCheck("ShowUnit") == "Yes")
         {
             dgvSalesInvoice.Columns["dgvtxtSalesInvoicembUnitName"].Visible = true;
         }
         else
         {
             dgvSalesInvoice.Columns["dgvtxtSalesInvoicembUnitName"].Visible = false;
         }
         if (spSettings.SettingsStatusCheck("ShowDiscountAmount") == "Yes")
         {
             dgvSalesInvoice.Columns["dgvtxtSalesInvoiceDiscountAmount"].Visible = true;
         }
         else
         {
             dgvSalesInvoice.Columns["dgvtxtSalesInvoiceDiscountAmount"].Visible = false;
         }
         if (spSettings.SettingsStatusCheck("ShowProductCode") == "Yes")
         {
             dgvSalesInvoice.Columns["dgvtxtSalesInvoiceProductCode"].Visible = true;
         }
         else
         {
             dgvSalesInvoice.Columns["dgvtxtSalesInvoiceProductCode"].Visible = false;
         }
         if (spSettings.SettingsStatusCheck("Barcode") == "Yes")
         {
             dgvSalesInvoice.Columns["dgvtxtSalesInvoiceBarcode"].Visible = true;
         }
         else
         {
             dgvSalesInvoice.Columns["dgvtxtSalesInvoiceBarcode"].Visible = false;
         }
         if (spSettings.SettingsStatusCheck("ShowDiscountPercentage") == "Yes")
         {
             dgvSalesInvoice.Columns["dgvtxtSalesInvoiceDiscountPercentage"].Visible = true;
         }
         else
         {
             dgvSalesInvoice.Columns["dgvtxtSalesInvoiceDiscountPercentage"].Visible = false;
         }
         if (spSettings.SettingsStatusCheck("AllowBatch") == "Yes")
         {
             dgvSalesInvoice.Columns["dgvcmbSalesInvoiceBatch"].Visible = true;
         }
         else
         {
             dgvSalesInvoice.Columns["dgvcmbSalesInvoiceBatch"].Visible = false;
         }
         if (spSettings.SettingsStatusCheck("ShowPurchaseRate") == "Yes")
         {
             dgvSalesInvoice.Columns["dgvtxtSalesInvoicePurchaseRate"].Visible = true;
         }
         else
         {
             dgvSalesInvoice.Columns["dgvtxtSalesInvoicePurchaseRate"].Visible = false;
         }
         if (spSettings.SettingsStatusCheck("Tax") == "Yes")
         {
             dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible = true;
             dgvSalesInvoice.Columns["dgvtxtSalesInvoiceTaxAmount"].Visible = true;
             dgvSalesInvoiceTax.Visible = true;
             lblTaxTotal.Visible = true;
             lblTaxTotalAmount.Visible = true;
         }
         else
         {
             dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible = false;
             dgvSalesInvoice.Columns["dgvtxtSalesInvoiceTaxAmount"].Visible = false;
             dgvSalesInvoiceTax.Visible = false;
             lblTaxTotal.Visible = false;
             lblTaxTotalAmount.Visible = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SI : 02" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// When Form Loads
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmDeliveryNote_Load(object sender, EventArgs e)
        {
            try
            {
                Clear();
                PrintCheck();
                FillProducts(false, null);
                SettingsSP Spsetting = new SettingsSP();
                if (Spsetting.SettingsStatusCheck("ShowProductCode") == "Yes")
                {
                    dgvProduct.Columns["dgvtxtProductCode"].Visible = true;
                }
                else
                {
                    dgvProduct.Columns["dgvtxtProductCode"].Visible = false;
                }
                if (Spsetting.SettingsStatusCheck("barcode") == "Yes")
                {
                    dgvProduct.Columns["dgvtxtBarcode"].Visible = true;
                }
                else
                {
                    dgvProduct.Columns["dgvtxtBarcode"].Visible = false;
                }
                if (Spsetting.SettingsStatusCheck("ShowUnit") == "Yes")
                {
                    dgvProduct.Columns["dgvcmbUnit"].Visible = true;
                }
                else
                {
                    dgvProduct.Columns["dgvcmbUnit"].Visible = false;
                }
                if (Spsetting.SettingsStatusCheck("AllowGodown") == "Yes")
                {
                    dgvProduct.Columns["dgvcmbGodown"].Visible = true;
                    dgvProduct.Columns["dgvcmbRack"].Visible = true;
                }
                else
                {
                    dgvProduct.Columns["dgvcmbGodown"].Visible = false;
                    dgvProduct.Columns["dgvcmbRack"].Visible = false;
                }
                if (Spsetting.SettingsStatusCheck("AllowRack") == "Yes")
                {
                    if (Spsetting.SettingsStatusCheck("AllowGodown") == "Yes")
                        dgvProduct.Columns["dgvcmbRack"].Visible = true;
                    else
                        dgvProduct.Columns["dgvcmbRack"].Visible = false;
                }
                else
                {
                    dgvProduct.Columns["dgvcmbRack"].Visible = false;
                }

                if (Spsetting.SettingsStatusCheck("AllowBatch") == "Yes")
                {
                    dgvProduct.Columns["dgvcmbBatch"].Visible = true;
                }
                else
                {
                    dgvProduct.Columns["dgvcmbBatch"].Visible = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("DN51:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Currency combo fill
 /// </summary>
 public void ComboCurrencyFill()
 {
     TransactionsGeneralFill transactionGeneralFillObj = new TransactionsGeneralFill();
     SettingsSP SpSettings = new SettingsSP();
     try
     {
         DataTable dtbl = new DataTable();
         dtbl = transactionGeneralFillObj.CurrencyComboByDate(Convert.ToDateTime(txtSalesQuotationDate.Text));
         cmbCurrency.DataSource = dtbl;
         cmbCurrency.DisplayMember = "currencyName";
         cmbCurrency.ValueMember = "exchangeRateId";
         cmbCurrency.SelectedValue = 1m;
         DataRow dr = dtbl.NewRow();
         if (SpSettings.SettingsStatusCheck("MultiCurrency") == "Yes")
         {
             cmbCurrency.Enabled = true;
         }
         else
         {
             cmbCurrency.Enabled = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SQ:13" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 ///  Save or edit function to checking the negative stock status
 /// </summary>
 public void SaveOrEditFunction()
 {
     try
     {
         decimal decProductId = 0;
         decimal decBatchId = 0;
         decimal decCalcQty = 0;
         StockPostingSP spStockPosting = new StockPostingSP();
         SettingsSP spSettings = new SettingsSP();
         string strStatus = spSettings.SettingsStatusCheck("NegativeStockStatus");
         bool isNegativeLedger = false;
         int inRowCount = dgvSalesInvoice.RowCount;
         for (int i = 0; i < inRowCount - 1; i++)
         {
             if (dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductId"].Value != null && dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductId"].Value.ToString() != string.Empty)
             {
                 decProductId = Convert.ToDecimal(dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductId"].Value.ToString());
                 if (dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceBatch"].Value != null && dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceBatch"].Value.ToString() != string.Empty)
                 {
                     decBatchId = Convert.ToDecimal(dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceBatch"].Value.ToString());
                 }
                 decimal decCurrentStock = spStockPosting.StockCheckForProductSale(decProductId, decBatchId);
                 if (dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceQty"].Value != null && dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceQty"].Value.ToString() != string.Empty)
                 {
                     decCalcQty = decCurrentStock - Convert.ToDecimal(dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceQty"].Value.ToString());
                 }
                 if (decCalcQty < 0)
                 {
                     isNegativeLedger = true;
                     break;
                 }
             }
         }
         if (isNegativeLedger)
         {
             if (strStatus == "Warn")
             {
                 if (MessageBox.Show("Negative Stock balance exists,Do you want to Continue", "Open miracle", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                 {
                     SaveOrEdit();
                 }
             }
             else if (strStatus == "Block")
             {
                 MessageBox.Show("Cannot continue ,due to negative stock balance", "Open miracle", MessageBoxButtons.OK, MessageBoxIcon.Stop);
             }
             else
             {
                 SaveOrEdit();
             }
         }
         else
         {
             SaveOrEdit();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SI : 68" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to check the BarCode status in settings
 /// </summary>
 /// <returns></returns>
 public bool ShowBarcode()
 {
     bool isShow = false;
     SettingsSP spSettings = new SettingsSP();
     try
     {
         isShow = spSettings.ShowBarcode();
     }
     catch (Exception ex)
     {
         MessageBox.Show("SQ:22" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return isShow;
 }
 /// <summary>
 /// Edit Function
 /// </summary>
 public void EditFunction()
 {
     try
     {
         removeSalesInvoiceDetails();
         SalesMasterSP spSalesMaster = new SalesMasterSP();
         SalesMasterInfo InfoSalesMaster = new SalesMasterInfo();
         InfoSalesMaster = spSalesMaster.SalesMasterView(decSalesInvoiceIdToEdit);
         if (InfoSalesMaster.DeliveryNoteMasterId != 0)
         {
             DeliveryNoteMasterInfo infoDeliveryNote = new DeliveryNoteMasterInfo();
             infoDeliveryNote = new DeliveryNoteMasterSP().DeliveryNoteMasterView(InfoSalesMaster.DeliveryNoteMasterId);
             new StockPostingSP().StockPostingDeleteForSalesInvoiceAgainstDeliveryNote
                 (InfoSalesMaster.VoucherTypeId, InfoSalesMaster.VoucherNo,
                 infoDeliveryNote.VoucherNo, infoDeliveryNote.VoucherTypeId);
         }
         new StockPostingSP().StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType
                 (0, "NA", InfoSalesMaster.VoucherNo, InfoSalesMaster.VoucherTypeId);
         InfoSalesMaster.SalesMasterId = decSalesInvoiceIdToEdit;
         InfoSalesMaster.AdditionalCost = Convert.ToDecimal(lblLedgerTotalAmount.Text);
         InfoSalesMaster.BillDiscount = Convert.ToDecimal(txtBillDiscount.Text.Trim());
         InfoSalesMaster.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text.Trim().ToString());
         InfoSalesMaster.CustomerName = txtCustomer.Text.Trim();
         InfoSalesMaster.Date = Convert.ToDateTime(txtDate.Text.ToString());
         InfoSalesMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
         InfoSalesMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString());
         InfoSalesMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
         InfoSalesMaster.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text.Trim());
         InfoSalesMaster.InvoiceNo = txtInvoiceNo.Text.Trim();
         InfoSalesMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
         InfoSalesMaster.VoucherTypeId = DecSalesInvoiceVoucherTypeId;
         InfoSalesMaster.VoucherNo = strVoucherNo;
         if (isAutomatic)
         {
             InfoSalesMaster.SuffixPrefixId = decSalseInvoiceSuffixPrefixId;
         }
         else
         {
             InfoSalesMaster.SuffixPrefixId = 0;
         }
         if (cmbSalesMode.Text == "Against SalesOrder")
         {
             InfoSalesMaster.OrderMasterId = Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString());
         }
         else
         {
             InfoSalesMaster.OrderMasterId = 0;
         }
         if (cmbSalesMode.Text == "Against Delivery Note")
         {
             InfoSalesMaster.DeliveryNoteMasterId = Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString());
         }
         else
         {
             InfoSalesMaster.DeliveryNoteMasterId = 0;
         }
         if (cmbSalesMode.Text == "Against Quotation")
         {
             InfoSalesMaster.QuotationMasterId = Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString());
         }
         else
         {
             InfoSalesMaster.QuotationMasterId = 0;
         }
         InfoSalesMaster.Narration = txtNarration.Text.Trim();
         InfoSalesMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString());
         InfoSalesMaster.SalesAccount = Convert.ToDecimal(cmbSalesAccount.SelectedValue.ToString());
         InfoSalesMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text.Trim());
         if (dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible)
         {
             InfoSalesMaster.TaxAmount = Convert.ToDecimal(lblTaxTotalAmount.Text.Trim());
         }
         else
         {
             InfoSalesMaster.TaxAmount = 0;
         }
         InfoSalesMaster.UserId = PublicVariables._decCurrentUserId;
         InfoSalesMaster.LrNo = txtVehicleNo.Text;
         InfoSalesMaster.TransportationCompany = txtTransportCompany.Text.Trim();
         InfoSalesMaster.POS = false;
         InfoSalesMaster.CounterId = 0;
         InfoSalesMaster.ExtraDate = DateTime.Now;
         InfoSalesMaster.Extra1 = string.Empty;
         InfoSalesMaster.Extra2 = string.Empty;
         spSalesMaster.SalesMasterEdit(InfoSalesMaster);
         removeSalesInvoiceDetails();
         SalesInvoiceDetailsEditFill();
         if (cmbCashOrParty.Enabled)
         {
             LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
             spLedgerPosting.LedgerPostDelete(strVoucherNo, DecSalesInvoiceVoucherTypeId);
             ledgerPostingAdd();
         }
         else
         {
             ledgerPostingEdit();
         }
         Messages.UpdatedMessage();
         if (cbxPrintAfterSave.Checked)
         {
             SettingsSP spSettings = new SettingsSP();
             if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
             {
                 PrintForDotMatrix(decSalesInvoiceIdToEdit);
             }
             else
             {
                 Print(decSalesInvoiceIdToEdit);
             }
         }
         this.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show("SI: 78" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #28
0
 /// <summary>
 /// Function to clear
 /// </summary>
 public void Clear()
 {
     try
     {
         SettingsSP spSettings = new SettingsSP();
         txtCustomerName.Text = string.Empty;
         txtMailingName.Text = string.Empty;
         txtOpeningBalance.Text = "0.00";
         cmbDrorCr.Text = "Dr";
         txtAccountNo.Text = string.Empty;
         txtBranchName.Text = string.Empty;
         txtBranchCode.Text = string.Empty;
         txtMobile.Text = string.Empty;
         txtphone.Text = string.Empty;
         txtAddress.Text = string.Empty;
         txtEmail.Text = string.Empty;
         if (spSettings.SettingsStatusCheck("BillByBill") == "Yes")
         {
             cmbBillbyBill.Enabled = true;
             cmbBillbyBill.Text = "No";
         }
         else
         {
             cmbBillbyBill.Enabled = false;
         }
         cmbBillbyBill.Text = "No";
         cmbPricingLevel.SelectedIndex = 0;
         txtCreditLimit.Text = string.Empty;
         txtCreditPeriod.Text = string.Empty;
         txtTin.Text = string.Empty;
         txtPan.Text = string.Empty;
         txtCST.Text = string.Empty;
         txtCustomerName.Focus();
         cmbArea.SelectedIndex = 0;
         txtNarration.Text = string.Empty; ;
         cmbRoute.SelectedIndex = 0;
         txtCustomerNameSearch.Text = string.Empty;
         cmbAreaSearch.SelectedIndex = 0;
         cmbRoutSearch.SelectedIndex = 0;
         btnDelete.Enabled = false;
         btnSave.Text = "Save";
         GridFill();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Cus12:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// On cellvalueChanged of dgvCreditNote
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvJournalVoucher_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex != -1 && e.ColumnIndex != -1)
                {
                    DebitAndCreditTotal();

                    if (dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value != null && dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
                    {

                        if (dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value == null || dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value.ToString() == string.Empty)
                        {
                            dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(1); //decExchangeRateId;
                        }

                    }

                    if (dgvJournalVoucher.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbAccountLedger")
                    {
                        /*************Remove partybalance while changing the ledger ************/
                        if (inUpdatingRowIndexForPartyRemove != -1)
                        {
                            int inTableRowCount = dtblPartyBalance.Rows.Count;
                            for (int inJ = 0; inJ < inTableRowCount; inJ++)
                            {
                                if (dtblPartyBalance.Rows.Count == inJ)
                                {
                                    break;
                                }

                                if (Convert.ToDecimal(dtblPartyBalance.Rows[inJ]["ledgerId"].ToString()) == decUpdatingLedgerForPartyremove)
                                {
                                    if (dtblPartyBalance.Rows[inJ]["PartyBalanceId"].ToString() != "0")
                                    {
                                        arrlstOfDeletedPartyBalanceRow.Add(dtblPartyBalance.Rows[inJ]["PartyBalanceId"]);
                                    }
                                    dtblPartyBalance.Rows.RemoveAt(inJ);
                                    inJ--;
                                }
                            }

                            dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty;

                            //reset
                            decUpdatingLedgerForPartyremove = 0;
                            inUpdatingRowIndexForPartyRemove = -1;
                        }
                        /*************************************************************************/

                        //-----------To make amount readonly when party is selected as ledger------------------------------//
                        AccountLedgerSP spAccountLedger = new AccountLedgerSP();
                        if (spAccountLedger.AccountGroupIdCheck(dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].FormattedValue.ToString()))
                        {
                            dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty;
                            dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].ReadOnly = true;

                        }
                        else
                        {
                            dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty;
                            dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].ReadOnly = false;
                            SettingsSP spSettings = new SettingsSP();
                            if (spSettings.SettingsStatusCheck("MultiCurrency") == "Yes")
                            {
                                dgvcmbCurrency.ReadOnly = false;
                            }
                            else
                            {
                                dgvcmbCurrency.ReadOnly = true;

                            }
                        }

                        //========================================================================================//
                    }

                    if (dgvJournalVoucher.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbDrOrCr")
                    {
                        /*************Remove partybalance while changing the Dr/Cr ************/
                        if (inUpdatingRowIndexForPartyRemove != -1)
                        {
                            int inTableRowCount = dtblPartyBalance.Rows.Count;
                            for (int inJ = 0; inJ < inTableRowCount; inJ++)
                            {
                                if (dtblPartyBalance.Rows.Count == inJ)
                                {
                                    break;
                                }

                                if (Convert.ToDecimal(dtblPartyBalance.Rows[inJ]["ledgerId"].ToString()) == decUpdatingLedgerForPartyremove)
                                {
                                    if (dtblPartyBalance.Rows[inJ]["PartyBalanceId"].ToString() != "0")
                                    {
                                        arrlstOfDeletedPartyBalanceRow.Add(dtblPartyBalance.Rows[inJ]["PartyBalanceId"]);
                                    }
                                    dtblPartyBalance.Rows.RemoveAt(inJ);
                                    inJ--;
                                }
                            }
                            dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty;

                            //reset
                            decUpdatingLedgerForPartyremove = 0;
                            inUpdatingRowIndexForPartyRemove = -1;
                        }
                        /*************************************************************************/
                    }

                    //-----------------------------------Chequedate validation----------------------------------//
                    DateValidation obj = new DateValidation();
                    TextBox txtDate1 = new TextBox();
                    if (dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value != null && dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty)
                    {
                        txtDate1.Text = dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value.ToString();
                        bool isInvalid = obj.DateValidationFunction(txtDate1);
                        if (!isInvalid)
                        {
                            dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
                        }
                        else
                        {
                            dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value = txtDate1.Text;
                        }
                    }
                    //=========================================================================================//
                    //---------------------check column missing---------------------------------//

                    CheckColumnMissing(e);

                    //==========================================================================//

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("JV50:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function for check settings
        /// </summary>
        public void InitialSettings()
        {

            try
            {
                SettingsSP spSettings = new SettingsSP();
                SettingsInfo info = new SettingsInfo();
                DataTable dtbl = new DataTable();
                dtbl = spSettings.SettingsViewAll();




                if (dtbl.Rows.Count > 0)
                {

                    foreach (DataRow item in dtbl.Rows)
                    {
                        info.SettingsName = item["settingsName"].ToString();
                        info.Status = item["status"].ToString();
                        if (info.SettingsName == "AllowBatch" && info.Status == "Yes")
                        {
                            cmbAllowBatch.Enabled = true;
                        }
                        if (info.SettingsName == "AllowBatch" && info.Status == "No")
                        {
                            cmbAllowBatch.Enabled = false;
                        }

                        if (info.SettingsName == "AllowSize" && info.Status == "Yes")
                        {
                            cmbSize.Enabled = true;
                            btnSizeAdd.Enabled = true;

                        }
                        if (info.SettingsName == "AllowSize" && info.Status == "No")
                        {
                            cmbSize.Enabled = false;
                            btnSizeAdd.Enabled = false;
                        }
                        if (info.SettingsName == "AllowModelNo" && info.Status == "Yes")
                        {
                            cmbModalNo.Enabled = true;
                            btnModalNo.Enabled = true;
                        }
                        if (info.SettingsName == "AllowModelNo" && info.Status == "No")
                        {
                            cmbModalNo.Enabled = false;
                            btnModalNo.Enabled = false;
                        }
                        if (info.SettingsName == "AllowGodown" && info.Status == "Yes")
                        {
                            cmbDefaultGodown.Enabled = true;
                            btnDefaultGodownAdd.Enabled = true;
                            dgvProductCreation.Columns["dgvcmbtgodown"].Visible = true;

                        }
                        if (info.SettingsName == "AllowGodown" && info.Status == "No")
                        {
                            cmbDefaultGodown.Enabled = false;
                            btnDefaultGodownAdd.Enabled = false;
                            dgvProductCreation.Columns["dgvcmbtgodown"].Visible = false;

                        }
                        if (info.SettingsName == "AllowRack" && info.Status == "Yes")
                        {
                            cmbDefaultRack.Enabled = true;
                            btnDefaultAdd.Enabled = true;

                            dgvProductCreation.Columns["dgvcmbrack"].Visible = true;


                        }
                        if (info.SettingsName == "AllowRack" && info.Status == "No")
                        {
                            cmbDefaultRack.Enabled = false;
                            btnDefaultAdd.Enabled = false;

                            dgvProductCreation.Columns["dgvcmbrack"].Visible = false;

                        }
                        if (info.SettingsName == "Tax" && info.Status == "No")
                        {
                            cmbTax.Enabled = false;
                            btnTaxAdd.Enabled = false;
                        }
                    }

                }



            }
            catch (Exception ex)
            {
                MessageBox.Show("PC:74" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }


        }
        /// <summary>
        /// Gridview cell value changed , doing basic calculations and checking invalid entries
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvPaymentVoucher_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex != -1 && e.ColumnIndex != -1)
                {
                    TotalAmount();

                    if (dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
                    {

                        if (dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value == null || dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value.ToString() == string.Empty)
                        {
                            dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(1);
                        }

                    }
                    AccountGroupSP spAccountGroup = new AccountGroupSP();
                    AccountLedgerSP SpAccountLedger = new AccountLedgerSP();
                    if (dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString().Trim() != string.Empty)
                    {
                        if (dgvPaymentVoucher.CurrentCell.ColumnIndex == dgvPaymentVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].ColumnIndex)
                        {

                            /*************Remove partybalance while changing the ledger ************/
                            if (inUpdatingRowIndexForPartyRemove != -1)
                            {
                                int inTableRowCount = dtblPartyBalance.Rows.Count;
                                for (int inJ = 0; inJ < inTableRowCount; inJ++)
                                {
                                    if (dtblPartyBalance.Rows.Count == inJ)
                                    {
                                        break;
                                    }
                                    if (Convert.ToDecimal(dtblPartyBalance.Rows[inJ]["ledgerId"].ToString()) == decUpdatingLedgerForPartyremove)
                                    {
                                        if (dtblPartyBalance.Rows[inJ]["PartyBalanceId"].ToString() != "0")
                                        {
                                            arrlstOfDeletedPartyBalanceRow.Add(dtblPartyBalance.Rows[inJ]["PartyBalanceId"]);
                                        }
                                        dtblPartyBalance.Rows.RemoveAt(inJ);
                                        inJ--;
                                    }
                                }
                                dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty;
                                decUpdatingLedgerForPartyremove = 0;
                                inUpdatingRowIndexForPartyRemove = -1;
                            }
                            /*************************************************************************/
                            decimal decLedgerId = Convert.ToDecimal(dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString());
                            bool IsBankAccount = spAccountGroup.AccountGroupwithLedgerId(decLedgerId);
                            decimal decI = Convert.ToDecimal(SpAccountLedger.AccountGroupIdCheck(dgvPaymentVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].FormattedValue.ToString()));
                            if (decI > 0)//to make amount and currency read only when party is choosen as ledger
                            {
                                dgvPaymentVoucher.CurrentRow.Cells["dgvtxtAmount"].ReadOnly = true;
                                dgvPaymentVoucher.CurrentRow.Cells["dgvtxtAmount"].Value = string.Empty;
                                dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(1);
                                dgvPaymentVoucher.CurrentRow.Cells["dgvcmbCurrency"].ReadOnly = true;
                            }
                            else
                            {
                                dgvPaymentVoucher.CurrentRow.Cells["dgvtxtAmount"].ReadOnly = false;
                                SettingsSP spSettings = new SettingsSP();
                                if (spSettings.SettingsStatusCheck("MultiCurrency") == "Yes")
                                {
                                    dgvcmbCurrency.ReadOnly = false;
                                }
                                else
                                {
                                    dgvcmbCurrency.ReadOnly = true;

                                }
                            }
                        }
                    }
                    CheckColumnMissing();
                    DateValidation objVal = new DateValidation();
                    TextBox txtDate1 = new TextBox();
                    if (dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value != null)
                    {

                        txtDate1.Text = dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value.ToString();
                        bool isDate = objVal.DateValidationFunction(txtDate1);
                        if (isDate)
                        {
                            dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value = txtDate1.Text;
                        }
                        else
                        {
                            dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PV48:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to check settings of ProductCode generation
        /// </summary>
        /// <returns></returns>
        public bool AutomaticProductCode()
        {

            try
            {
                SettingsSP spSetting = new SettingsSP();
                isAuto = spSetting.AutomaticProductCodeGeneration();

            }
            catch (Exception ex)
            {
                MessageBox.Show("PC:16" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return isAuto;
        }
 /// <summary>
 /// Function to set the calculation method by checking the settings
 /// </summary>
 public void CalculationMethod()
 {
     try
     {
         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";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("AGR:6" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #34
0
 /// <summary>
 /// Checking the general settings before loading the MDI page.
 /// This either enables or disables the controls on the form depending on the current settings
 /// </summary>
 public void SettingsCheck()
 {
     try
     {
         SettingsSP spSettings = new SettingsSP();
         if (spSettings.SettingsStatusCheck("Tax") == "Yes")
         {
             formMDI.MDIObj.taxToolStripMenuItem.Enabled = true;
         }
         else
         {
             formMDI.MDIObj.taxToolStripMenuItem.Enabled = false;
         }
         if (spSettings.SettingsStatusCheck("Budget") == "Yes")
         {
             formMDI.MDIObj.budgetToolStripMenuItem.Enabled = true;
         }
         else
         {
             formMDI.MDIObj.budgetToolStripMenuItem.Enabled = false;
         }
         if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
         {
             formMDI.MDIObj.payrollToolStripMenuItem.Enabled = true;
             formMDI.MDIObj.payrollToolStripMenuItem1.Enabled = true;
             foreach (ToolStripMenuItem toolItem in formMDI.MDIObj.payrollToolStripMenuItem1.DropDownItems)
             {
                 toolItem.Enabled = true;
             }
         }
         else
         {
             formMDI.MDIObj.payrollToolStripMenuItem.Enabled = false;
             formMDI.MDIObj.payrollToolStripMenuItem1.Enabled = false;
             foreach (ToolStripMenuItem toolItem in formMDI.MDIObj.payrollToolStripMenuItem1.DropDownItems)
             {
                 toolItem.Enabled = false;
             }
         }
         if (spSettings.SettingsStatusCheck("MultiCurrency") == "Yes")
         {
             formMDI.MDIObj.currencyToolStripMenuItem.Enabled = true;
         }
         else
         {
             formMDI.MDIObj.currencyToolStripMenuItem.Enabled = false;
         }
         if (spSettings.SettingsStatusCheck("AllowBatch") == "Yes")
         {
             formMDI.MDIObj.batchToolStripMenuItem.Enabled = true;
         }
         else
         {
             formMDI.MDIObj.batchToolStripMenuItem.Enabled = false;
         }
         if (spSettings.SettingsStatusCheck("AllowSize") == "Yes")
         {
             formMDI.MDIObj.sizeToolStripMenuItem.Enabled = true;
         }
         else
         {
             formMDI.MDIObj.sizeToolStripMenuItem.Enabled = false;
         }
         if (spSettings.SettingsStatusCheck("AllowGodown") == "Yes")
         {
             formMDI.MDIObj.godownToolStripMenuItem.Enabled = true;
             if (spSettings.SettingsStatusCheck("AllowRack") == "Yes")
             {
                 formMDI.MDIObj.rackToolStripMenuItem.Enabled = true;
             }
             else
             {
                 formMDI.MDIObj.rackToolStripMenuItem.Enabled = false;
             }
         }
         else
         {
             formMDI.MDIObj.godownToolStripMenuItem.Enabled = false;
             formMDI.MDIObj.rackToolStripMenuItem.Enabled = false;
         }
         if (spSettings.SettingsStatusCheck("AllowModelNo") == "Yes")
         {
             formMDI.MDIObj.modelNumberToolStripMenuItem.Enabled = true;
         }
         else
         {
             formMDI.MDIObj.modelNumberToolStripMenuItem.Enabled = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("LOGIN:"******"OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #35
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);
        }
Exemple #36
0
 /// <summary>
 /// Checking the general settings before loading the MDI page.
 /// This either enables or disables the controls on the form depending on the current settings
 /// </summary>
 public void SettingsCheck()
 {
     try
     {
         SettingsSP spSettings = new SettingsSP();
         if (spSettings.SettingsStatusCheck("Tax") == "Yes")
         {
             formMDI.MDIObj.taxToolStripMenuItem.Enabled = true;
         }
         else
         {
             formMDI.MDIObj.taxToolStripMenuItem.Enabled = false;
         }
         if (spSettings.SettingsStatusCheck("Budget") == "Yes")
         {
             formMDI.MDIObj.budgetToolStripMenuItem.Enabled = true;
         }
         else
         {
             formMDI.MDIObj.budgetToolStripMenuItem.Enabled = false;
         }
         if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
         {
             formMDI.MDIObj.payrollToolStripMenuItem.Enabled  = true;
             formMDI.MDIObj.payrollToolStripMenuItem1.Enabled = true;
             foreach (ToolStripMenuItem toolItem in formMDI.MDIObj.payrollToolStripMenuItem1.DropDownItems)
             {
                 toolItem.Enabled = true;
             }
         }
         else
         {
             formMDI.MDIObj.payrollToolStripMenuItem.Enabled  = false;
             formMDI.MDIObj.payrollToolStripMenuItem1.Enabled = false;
             foreach (ToolStripMenuItem toolItem in formMDI.MDIObj.payrollToolStripMenuItem1.DropDownItems)
             {
                 toolItem.Enabled = false;
             }
         }
         if (spSettings.SettingsStatusCheck("MultiCurrency") == "Yes")
         {
             formMDI.MDIObj.currencyToolStripMenuItem.Enabled = true;
         }
         else
         {
             formMDI.MDIObj.currencyToolStripMenuItem.Enabled = false;
         }
         if (spSettings.SettingsStatusCheck("AllowBatch") == "Yes")
         {
             formMDI.MDIObj.batchToolStripMenuItem.Enabled = true;
         }
         else
         {
             formMDI.MDIObj.batchToolStripMenuItem.Enabled = false;
         }
         if (spSettings.SettingsStatusCheck("AllowSize") == "Yes")
         {
             formMDI.MDIObj.sizeToolStripMenuItem.Enabled = true;
         }
         else
         {
             formMDI.MDIObj.sizeToolStripMenuItem.Enabled = false;
         }
         if (spSettings.SettingsStatusCheck("AllowGodown") == "Yes")
         {
             formMDI.MDIObj.godownToolStripMenuItem.Enabled = true;
             if (spSettings.SettingsStatusCheck("AllowRack") == "Yes")
             {
                 formMDI.MDIObj.rackToolStripMenuItem.Enabled = true;
             }
             else
             {
                 formMDI.MDIObj.rackToolStripMenuItem.Enabled = false;
             }
         }
         else
         {
             formMDI.MDIObj.godownToolStripMenuItem.Enabled = false;
             formMDI.MDIObj.rackToolStripMenuItem.Enabled   = false;
         }
         if (spSettings.SettingsStatusCheck("AllowModelNo") == "Yes")
         {
             formMDI.MDIObj.modelNumberToolStripMenuItem.Enabled = true;
         }
         else
         {
             formMDI.MDIObj.modelNumberToolStripMenuItem.Enabled = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("LOGIN:"******"OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to remove incomplete rows from production grid
        /// </summary>
        /// <returns></returns>
        public bool RemoveIncompleteRowsFromProductionGrid()
        {
            SettingsSP spSettings = new SettingsSP();
            bool isOk = true;
            try
            {
                string strMessage = "Rows";
                int inC = 0, inForFirst = 0;
                int inRowcount = dgvConsumption.RowCount;
                int inLastRow = 1;
                foreach (DataGridViewRow dgvrowCur in dgvProduction.Rows)
                {
                    if (inLastRow < inRowcount)
                    {
                        if (dgvrowCur.HeaderCell.Value != null)
                        {
                            if (spSettings.SettingsStatusCheck("AllowZeroValueEntry") == "No" && Convert.ToDecimal(dgvrowCur.Cells["dgvtxtProductionAmount"].Value) == 0)
                            {
                                dgvProduction.CurrentRow.HeaderCell.Value = "X";
                                dgvProduction.CurrentRow.HeaderCell.Style.ForeColor = Color.Red;

                            }
                            if (dgvrowCur.HeaderCell.Value.ToString() == "X" || dgvrowCur.Cells["dgvtxtProductionProductName"].Value == null)
                            {
                                isOk = false;
                                if (inC == 0)
                                {
                                    strMessage = strMessage + Convert.ToString(dgvrowCur.Index + 1);
                                    inForFirst = dgvrowCur.Index;
                                    inC++;
                                }
                                else
                                {
                                    strMessage = strMessage + ", " + Convert.ToString(dgvrowCur.Index + 1);
                                }
                            }
                        }
                    }
                    inLastRow++;
                }
                inLastRow = 1;
                if (!isOk)
                {
                    strMessage = strMessage + " contains invalid entries. Do you want to continue?";
                    if (MessageBox.Show(strMessage, "OpenMiracle", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                    {
                        isOk = true;
                        for (int inK = 0; inK < dgvProduction.Rows.Count; inK++)
                        {
                            if (dgvProduction.Rows[inK].HeaderCell.Value != null && dgvProduction.Rows[inK].HeaderCell.Value.ToString() == "X")
                            {
                                if (!dgvProduction.Rows[inK].IsNewRow)
                                {
                                    dgvProduction.Rows.RemoveAt(inK);
                                    inK--;
                                    ProductionSerialNo();
                                }
                            }
                        }
                    }
                    else
                    {
                        dgvProduction.Focus();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("SJ:38" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return isOk;
        }
Exemple #38
0
 /// <summary>
 /// Function to get the status of settings
 /// </summary>
 public void CurrentSettings()
 {
     try
     {
         SettingsSP spSettings = new SettingsSP();
         SettingsInfo infoSettings = new SettingsInfo();
         if (spSettings.SettingsStatusCheck("AddConfirmationFor") == "Yes")
         {
             if (spSettings.SettingsStatusCheck("Add") == "Yes")
             {
                 PublicVariables.isMessageAdd = true;
             }
             else
             {
                 PublicVariables.isMessageAdd = false;
             }
             if (spSettings.SettingsStatusCheck("Edit") == "Yes")
             {
                 PublicVariables.isMessageEdit = true;
             }
             else
             {
                 PublicVariables.isMessageEdit = false;
             }
             if (spSettings.SettingsStatusCheck("Delete") == "Yes")
             {
                 PublicVariables.isMessageDelete = true;
             }
             else
             {
                 PublicVariables.isMessageDelete = false;
             }
             if (spSettings.SettingsStatusCheck("Close") == "Yes")
             {
                 PublicVariables.isMessageClose = true;
             }
             else
             {
                 PublicVariables.isMessageClose = false;
             }
         }
         else
         {
             PublicVariables.isMessageAdd = PublicVariables.isMessageClose = PublicVariables.isMessageDelete = PublicVariables.isMessageEdit = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("MDI 3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to check invalid entries in production grid
        /// </summary>
        /// <param name="e"></param>
        public void CheckInvalidEntriesProduction(DataGridViewCellEventArgs e)
        {
            try
            {
                SettingsSP spSettings = new SettingsSP();
                if (dgvProduction.CurrentRow != null)
                {
                    if (!isValueChanged)
                    {
                        if (dgvProduction.CurrentRow.Cells["dgvtxtProductionProductName"].Value == null || dgvProduction.CurrentRow.Cells["dgvtxtProductionProductName"].Value.ToString().Trim() == string.Empty)
                        {
                            isValueChanged = true;
                            dgvProduction.CurrentRow.HeaderCell.Value = "X";
                            dgvProduction.CurrentRow.HeaderCell.Style.ForeColor = Color.Red;
                        }
                        else if (dgvProduction.CurrentRow.Cells["dgvtxtProductionQty"].Value == null || dgvProduction.CurrentRow.Cells["dgvtxtProductionQty"].Value.ToString().Trim() == string.Empty || Convert.ToDecimal(dgvProduction.CurrentRow.Cells["dgvtxtProductionQty"].Value) == 0)
                        {
                            isValueChanged = true;
                            dgvProduction.CurrentRow.HeaderCell.Value = "X";
                            dgvProduction.CurrentRow.HeaderCell.Style.ForeColor = Color.Red;
                        }

                        else if (spSettings.SettingsStatusCheck("AllowZeroValueEntry") == "No" && Convert.ToDecimal(dgvProduction.CurrentRow.Cells["dgvtxtProductionRate"].Value) == 0)
                        {

                            dgvProduction.CurrentRow.HeaderCell.Value = "X";
                            dgvProduction.CurrentRow.HeaderCell.Style.ForeColor = Color.Red;
                        }
                        else
                        {
                            isValueChanged = true;
                            dgvProduction.CurrentRow.HeaderCell.Value = string.Empty;
                        }
                    }
                    isValueChanged = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("SJ:42" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Save Function
        /// </summary>
        public void SaveFunction()
        {
            try
            {
                DeliveryNoteMasterInfo infoDeliveryNoteMaster = new DeliveryNoteMasterInfo();
                DeliveryNoteDetailsInfo infoDeliveryNoteDetails = new DeliveryNoteDetailsInfo();
                StockPostingInfo infoStockPosting = new StockPostingInfo();
                StockPostingSP spStockPosting = new StockPostingSP();
                DeliveryNoteMasterSP spDeliveryNoteMaster = new DeliveryNoteMasterSP();
                DeliveryNoteDetailsSP spDeliveryNoteDetails = new DeliveryNoteDetailsSP();
                SalesOrderMasterInfo infoSalesOrderMaster = new SalesOrderMasterInfo();
                SalesOrderMasterSP spSalesOrderMaster = new SalesOrderMasterSP();
                SalesQuotationMasterInfo infoSalesQuotationMaster = new SalesQuotationMasterInfo();
                SalesQuotationMasterSP spSalesQuotationMaster = new SalesQuotationMasterSP();
                infoDeliveryNoteMaster.InvoiceNo = txtDeliveryNoteNo.Text;
                infoDeliveryNoteMaster.VoucherTypeId = decDeliveryNoteVoucherTypeId;
                infoDeliveryNoteMaster.Date = Convert.ToDateTime(txtDate.Text);
                infoDeliveryNoteMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
                infoDeliveryNoteMaster.VoucherNo = strVoucherNo;
                infoDeliveryNoteMaster.SuffixPrefixId = decDeliveryNoteSuffixPrefixId;
                if (btnSave.Text == "Save")
                {
                    if (cmbOrderNo.SelectedValue != null)
                    {
                        if (cmbDeliveryMode.Text == "Against Order")
                        {
                            infoDeliveryNoteMaster.OrderMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString());
                            infoSalesOrderMaster = spSalesOrderMaster.SalesOrderMasterView(infoDeliveryNoteMaster.OrderMasterId);
                        }
                        else if (cmbDeliveryMode.Text == "Against Quotation")
                        {
                            infoDeliveryNoteMaster.QuotationMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString());
                            infoSalesQuotationMaster = spSalesQuotationMaster.SalesQuotationMasterView(infoDeliveryNoteMaster.QuotationMasterId);
                        }
                        else if (cmbDeliveryMode.Text == "NA")
                        {
                            infoDeliveryNoteMaster.OrderMasterId = 0; infoDeliveryNoteMaster.QuotationMasterId = 0;
                        }
                    }
                    else
                    {
                        infoDeliveryNoteMaster.OrderMasterId = 0;
                        infoDeliveryNoteMaster.QuotationMasterId = 0;
                    }
                    infoDeliveryNoteMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString());
                    if (cmbSalesMan.SelectedIndex != -1)
                    {
                        infoDeliveryNoteMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString());
                    }
                    else
                    {
                        infoDeliveryNoteMaster.EmployeeId = 0;
                    }
                    infoDeliveryNoteMaster.Narration = txtNarration.Text;
                    infoDeliveryNoteMaster.TotalAmount = Convert.ToDecimal(txtTotalAmnt.Text);
                    infoDeliveryNoteMaster.UserId = PublicVariables._decCurrentUserId;
                    infoDeliveryNoteMaster.LrNo = txtLRNo.Text;
                    infoDeliveryNoteMaster.TransportationCompany = txtTraspotationCompany.Text;
                    infoDeliveryNoteMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                    infoDeliveryNoteMaster.Extra1 = string.Empty;
                    infoDeliveryNoteMaster.Extra2 = string.Empty;
                    infoDeliveryNoteMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
                    if (decDelivryNoteIdToEdit == 0)
                    {
                        decDeliveryNoteMasterId = Convert.ToDecimal(spDeliveryNoteMaster.DeliveryNoteMasterAdd(infoDeliveryNoteMaster));
                    }
                    int inRowcount = dgvProduct.Rows.Count;
                    for (int inI = 0; inI < inRowcount - 1; inI++)
                    {
                        if (dgvProduct.Rows[inI].Cells["dgvtxtDetailsId"].Value == null)
                        {
                            if (cmbDeliveryMode.Text == "Against Order")
                            {
                                if (dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value != null)
                                {
                                    infoDeliveryNoteDetails.OrderDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value == null ? string.Empty : dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString());
                                }
                                else
                                {
                                    infoDeliveryNoteDetails.OrderDetails1Id = 0;
                                    infoDeliveryNoteDetails.QuotationDetails1Id = 0;
                                }
                            }
                            else if (cmbDeliveryMode.Text == "Against Quotation")
                            {
                                if (dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value != null)
                                {
                                    infoDeliveryNoteDetails.QuotationDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value == null ? string.Empty : dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString());
                                }
                                else
                                {
                                    infoDeliveryNoteDetails.OrderDetails1Id = 0;
                                    infoDeliveryNoteDetails.QuotationDetails1Id = 0;
                                }
                            }
                            else if (cmbDeliveryMode.Text == "NA")
                            {
                                infoDeliveryNoteDetails.OrderDetails1Id = 0;
                                infoDeliveryNoteDetails.QuotationDetails1Id = 0;
                            }
                        }
                        else
                        {
                            if (cmbOrderNo.SelectedText != string.Empty)
                            {
                                if (cmbDeliveryMode.Text == "Against Order")
                                {
                                    infoDeliveryNoteDetails.OrderDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString());
                                }
                                else if (cmbDeliveryMode.Text == "Against Quotation")
                                {
                                    infoDeliveryNoteDetails.QuotationDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString());
                                }
                                else if (cmbDeliveryMode.Text == "NA")
                                {
                                    infoDeliveryNoteDetails.OrderDetails1Id = 0;
                                    infoDeliveryNoteDetails.QuotationDetails1Id = 0;
                                }
                            }
                            else
                            {
                                infoDeliveryNoteDetails.OrderDetails1Id = 0;
                                infoDeliveryNoteDetails.QuotationDetails1Id = 0;
                            }
                        }
                        infoDeliveryNoteDetails.ProductId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtProductId"].Value.ToString());
                        infoDeliveryNoteDetails.Qty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString());
                        infoDeliveryNoteDetails.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString());
                        infoDeliveryNoteDetails.UnitId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString());
                        infoDeliveryNoteDetails.Amount = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                        infoDeliveryNoteDetails.UnitConversionId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString());
                        infoDeliveryNoteDetails.RackId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbRack"].Value.ToString());
                        infoDeliveryNoteDetails.BatchId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString());
                        infoDeliveryNoteDetails.GodownId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value.ToString());
                        infoDeliveryNoteDetails.SlNo = Convert.ToInt32(dgvProduct.Rows[inI].Cells["Col"].Value.ToString());
                        infoDeliveryNoteDetails.Extra1 = string.Empty;
                        infoDeliveryNoteDetails.Extra2 = string.Empty;
                        if (decDelivryNoteIdToEdit == 0)
                        {
                            infoDeliveryNoteDetails.DeliveryNoteMasterId = decDeliveryNoteMasterId;
                            spDeliveryNoteDetails.DeliveryNoteDetailsAdd(infoDeliveryNoteDetails);
                        }
                        else
                        {
                            infoDeliveryNoteDetails.DeliveryNoteMasterId = decDelivryNoteIdToEdit;
                            spDeliveryNoteDetails.DeliveryNoteDetailsEdit(infoDeliveryNoteDetails);
                        }
                        infoStockPosting.Date = Convert.ToDateTime(txtDate.Text);
                        if (dgvProduct.Rows[inI].Cells["dgvtxtVoucherTypeId"].Value != null)
                        {
                            if (cmbDeliveryMode.SelectedItem.ToString() != "NA")
                            {
                                if (dgvProduct.Rows[inI].Cells["dgvtxtVoucherTypeId"].Value != null)
                                {
                                    infoStockPosting.VoucherTypeId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtVoucherTypeId"].Value);
                                }
                                else
                                {
                                    infoStockPosting.VoucherTypeId = 0;
                                }
                                if (dgvProduct.Rows[inI].Cells["dgvtxtVoucherNo"].Value != null)
                                {
                                    infoStockPosting.VoucherNo = dgvProduct.Rows[inI].Cells["dgvtxtVoucherNo"].Value.ToString();
                                }
                                else
                                {
                                    infoStockPosting.VoucherNo = string.Empty;
                                }
                                if (dgvProduct.Rows[inI].Cells["dgvtxtInvoiceNo"].Value != null)
                                {
                                    infoStockPosting.InvoiceNo = dgvProduct.Rows[inI].Cells["dgvtxtInvoiceNo"].Value.ToString();
                                }
                                else
                                {
                                    infoStockPosting.InvoiceNo = string.Empty;
                                }
                                if (decDeliveryNoteVoucherTypeId != 0)
                                {
                                    infoStockPosting.AgainstVoucherTypeId = decDeliveryNoteVoucherTypeId;
                                }
                                else
                                {
                                    infoStockPosting.AgainstVoucherTypeId = 0;
                                }
                                if (strVoucherNo != string.Empty)
                                {
                                    infoStockPosting.AgainstVoucherNo = strVoucherNo;
                                }
                                else
                                {
                                    infoStockPosting.AgainstVoucherNo = string.Empty;
                                }
                                if (txtDeliveryNoteNo.Text != string.Empty)
                                {
                                    infoStockPosting.AgainstInvoiceNo = txtDeliveryNoteNo.Text;
                                }
                                else
                                {
                                    infoStockPosting.AgainstInvoiceNo = string.Empty;
                                }
                            }
                        }
                        else
                        {
                            infoStockPosting.InvoiceNo = txtDeliveryNoteNo.Text;
                            infoStockPosting.VoucherNo = strVoucherNo;
                            infoStockPosting.VoucherTypeId = decDeliveryNoteVoucherTypeId;
                            infoStockPosting.AgainstVoucherTypeId = 0;
                            infoStockPosting.AgainstVoucherNo = "NA";
                            infoStockPosting.AgainstInvoiceNo = "NA";
                        }
                        infoStockPosting.ProductId = infoDeliveryNoteDetails.ProductId;
                        infoStockPosting.BatchId = infoDeliveryNoteDetails.BatchId;
                        infoStockPosting.UnitId = infoDeliveryNoteDetails.UnitId;
                        infoStockPosting.GodownId = infoDeliveryNoteDetails.GodownId;
                        infoStockPosting.RackId = infoDeliveryNoteDetails.RackId;
                        infoStockPosting.OutwardQty = infoDeliveryNoteDetails.Qty;
                        infoStockPosting.Rate = infoDeliveryNoteDetails.Rate;
                        infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                        infoStockPosting.Extra1 = string.Empty;
                        infoStockPosting.Extra2 = string.Empty;
                        spStockPosting.StockPostingAdd(infoStockPosting);
                    }
                    Messages.SavedMessage();
                    if (cbxPrint.Checked)
                    {
                        SettingsSP spSettings = new SettingsSP();
                        if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                        {
                            PrintForDotMatrix(decDeliveryNoteMasterId);
                        }
                        else
                        {
                            Print(decDeliveryNoteMasterId);
                        }
                    }
                }
                if (btnSave.Text == "Update")
                {
                    SettingsSP spSettings = new SettingsSP();
                    infoDeliveryNoteMaster.DeliveryNoteMasterId = decDelivryNoteIdToEdit;
                    infoDeliveryNoteMaster.SuffixPrefixId = Convert.ToDecimal(decDeliveryNoteSuffixPrefixId);
                    infoDeliveryNoteMaster.VoucherNo = strVoucherNo;
                    infoDeliveryNoteMaster.UserId = PublicVariables._decCurrentUserId;//by default current userid used as current employeeid
                    infoDeliveryNoteMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString());
                    if (cmbSalesMan.SelectedIndex != -1)
                    {
                        infoDeliveryNoteMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString());
                    }
                    else
                    {
                        infoDeliveryNoteMaster.EmployeeId = 0;
                    }
                    infoDeliveryNoteMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;

                    if (cmbOrderNo.SelectedValue != null)
                    {
                        if (cmbDeliveryMode.Text == "Against Order")
                        {
                            infoDeliveryNoteMaster.OrderMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString());
                            infoSalesOrderMaster = spSalesOrderMaster.SalesOrderMasterView(infoDeliveryNoteMaster.OrderMasterId);
                        }
                        else if (cmbDeliveryMode.Text == "Against Quotation")
                        {
                            infoDeliveryNoteMaster.QuotationMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString());
                            infoSalesQuotationMaster = spSalesQuotationMaster.SalesQuotationMasterView(infoDeliveryNoteMaster.QuotationMasterId);
                        }
                        else if (cmbDeliveryMode.Text == "NA")
                        {
                            infoDeliveryNoteMaster.OrderMasterId = 0; infoDeliveryNoteMaster.QuotationMasterId = 0;
                        }
                    }
                    else
                    {
                        infoDeliveryNoteMaster.OrderMasterId = 0;
                        infoDeliveryNoteMaster.QuotationMasterId = 0;
                    }
                    infoDeliveryNoteMaster.Narration = txtNarration.Text.Trim();
                    infoDeliveryNoteMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
                    infoDeliveryNoteMaster.TotalAmount = Convert.ToDecimal(txtTotalAmnt.Text);
                    infoDeliveryNoteMaster.TransportationCompany = txtTraspotationCompany.Text;
                    infoDeliveryNoteMaster.LrNo = txtLRNo.Text;
                    infoDeliveryNoteMaster.Extra1 = string.Empty;
                    infoDeliveryNoteMaster.Extra2 = string.Empty;
                    spDeliveryNoteMaster.DeliveryNoteMasterEdit(infoDeliveryNoteMaster);
                    RemoveDeliveryNoteDetails();
                    infoDeliveryNoteMaster.VoucherTypeId = decDeliveryNoteVoucherTypeId;
                    spDeliveryNoteMaster.StockPostDeletingForDeliveryNote(decDeliveryNoteVoucherTypeId, strVoucherNo, txtDeliveryNoteNo.Text);
                    DeliveryNoteDetails();
                    Messages.UpdatedMessage();
                    if (frmDeliveryNoteRegisterObj != null)
                    {
                        if (cbxPrint.Checked)
                        {
                            if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                            {
                                PrintForDotMatrix(decDelivryNoteIdToEdit);
                            }
                            else
                            {
                                Print(decDelivryNoteIdToEdit);
                            }
                        }
                        frmDeliveryNoteRegisterObj.GridFill();
                    }
                    if (frmDeliveryNoteReportObj != null)
                    {
                        if (cbxPrint.Checked)
                        {
                            if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                            {
                                PrintForDotMatrix(decDelivryNoteIdToEdit);
                            }
                            else
                            {
                                Print(decDelivryNoteIdToEdit);
                            }
                        }
                        frmDeliveryNoteReportObj.GridFill();
                    }
                    this.Close();
                }
                Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show("DN35:" + 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;
            }
        }
        /// <summary>
        /// Calls the corresponding voucher on click in Quick Launch menu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn1_Click(object sender, EventArgs e)
        {
            this.SendToBack();
            Form       frmObj     = null;
            Form       open       = null;
            SettingsSP spSettings = new SettingsSP();

            try
            {
                string str = ((Button)sender).Text;
                btnFocus.Focus();
                switch (str)
                {
                case "Contra Voucher":
                    formMDI.MDIObj.ContraVoucherClick();
                    break;

                case "Payment Voucher":
                    formMDI.MDIObj.PaymentVoucherClick();
                    break;

                case "Receipt Voucher":
                    formMDI.MDIObj.ReceiptVoucherClick();
                    break;

                case "Journal Voucher":
                    formMDI.MDIObj.JournalVoucherClick();
                    break;

                case "Sales Invoice":
                    formMDI.MDIObj.SalesInvoiceClick();
                    break;

                case "Purchase Invoice":
                    formMDI.MDIObj.PurchaseInvoiceClick();
                    break;

                case "POS":
                    formMDI.MDIObj.POSClick();
                    break;

                case "PDC Payable":
                    formMDI.MDIObj.PDCPayableClick();
                    break;

                case "PDC Receivable":
                    formMDI.MDIObj.PDCReceivableClick();
                    break;

                case "PDC Clearance":
                    formMDI.MDIObj.PDCClearenceClick();
                    break;

                case "Bank Reconciliation":
                    frmObj = new frmBankReconciliation();
                    open   = Application.OpenForms["frmBankReconciliation"] as frmBankReconciliation;
                    break;

                case "Purchase Order":
                    formMDI.MDIObj.PurchaseOrderClick();
                    break;

                case "Material Reciept":
                    formMDI.MDIObj.MaterialReceiptClick();
                    break;

                case "Rejection Out":
                    formMDI.MDIObj.RejectionOutClick();
                    break;

                case "Purchase Return":
                    formMDI.MDIObj.PurchaseReturnClick();
                    break;

                case "Sales Quotation":
                    formMDI.MDIObj.SalesQuotationClick();
                    break;

                case "Sales Order":
                    formMDI.MDIObj.SalesOrderClick();
                    break;

                case "Delivery Note":
                    formMDI.MDIObj.DeliveryNoteClick();
                    break;

                case "Rejection In":
                    formMDI.MDIObj.RejectionInClick();
                    break;

                case "Sales Return":
                    formMDI.MDIObj.SalesReturnClick();
                    break;

                case "Physical Stock":
                    formMDI.MDIObj.PhysicalStockClick();
                    break;

                case "Service Voucher":
                    formMDI.MDIObj.ServiceVoucherClick();
                    break;

                case "Credit Note":
                    formMDI.MDIObj.CreditNoteClick();
                    break;

                case "Debit Note":
                    formMDI.MDIObj.DebitNoteClick();
                    break;

                case "Stock Journal":
                    //frmObj = new frmStockJournal();
                    //open = Application.OpenForms["frmStockJournal"] as frmStockJournal;
                    formMDI.MDIObj.StockJournalClick();
                    break;

                case "Bill Allocation":
                    frmObj = new frmBillallocation();
                    open   = Application.OpenForms["frmBillallocation"] as frmBillallocation;
                    break;

                case "Account Group":
                    frmObj = new frmAccountGroup();
                    open   = Application.OpenForms["frmAccountGroup"] as frmAccountGroup;
                    break;

                case "Account Ledger":
                    frmObj = new frmAccountLedger();
                    open   = Application.OpenForms["frmAccountLedger"] as frmAccountLedger;
                    break;

                case "Multiple Account Ledgers":
                    frmObj = new frmmultipleAccountLedger();
                    open   = Application.OpenForms["frmmultipleAccountLedger"] as frmmultipleAccountLedger;
                    break;

                case "Product Group":
                    frmObj = new frmProductGroup();
                    open   = Application.OpenForms["frmProductGroup"] as frmProductGroup;
                    break;

                case "Product Creation":
                    frmObj = new frmProductCreation();
                    open   = Application.OpenForms["frmProductCreation"] as frmProductCreation;
                    break;

                case "Multiple Product Creation":
                    frmObj = new frmMultipleProductCreation();
                    open   = Application.OpenForms["frmMultipleProductCreation"] as frmMultipleProductCreation;
                    break;

                case "Batch":
                    if (spSettings.SettingsStatusCheck("AllowBatch") == "Yes")
                    {
                        frmObj = new frmBatch();
                        open   = Application.OpenForms["frmBatch"] as frmBatch;
                    }
                    break;

                case "Brand":
                    frmObj = new frmBrand();
                    open   = Application.OpenForms["frmBrand"] as frmBrand;
                    break;

                case "Model Number":
                    if (spSettings.SettingsStatusCheck("AllowModelNo") == "Yes")
                    {
                        frmObj = new frmModalNo();
                        open   = Application.OpenForms["frmModalNo"] as frmModalNo;
                    }
                    break;

                case "Size":
                    if (spSettings.SettingsStatusCheck("AllowSize") == "Yes")
                    {
                        frmObj = new frmSize();
                        open   = Application.OpenForms["frmSize"] as frmSize;
                    }
                    break;

                case "Unit":
                    frmObj = new frmUnit();
                    open   = Application.OpenForms["frmUnit"] as frmUnit;
                    break;

                case "Godown":
                    if (spSettings.SettingsStatusCheck("AllowGodown") == "Yes")
                    {
                        frmObj = new frmGodown();
                        open   = Application.OpenForms["frmGodown"] as frmGodown;
                    }
                    break;

                case "Rack":
                    if (spSettings.SettingsStatusCheck("AllowRack") == "Yes")
                    {
                        frmObj = new frmRack();
                        open   = Application.OpenForms["frmRack"] as frmRack;
                    }
                    break;

                case "Pricing Level":
                    frmObj = new frmPricingLevel();
                    open   = Application.OpenForms["frmPricingLevel"] as frmPricingLevel;
                    break;

                case "Price List":
                    frmObj = new frmPriceList();
                    open   = Application.OpenForms["frmPriceList"] as frmPriceList;
                    break;

                case "Standard Rate":
                    frmObj = new frmStandardRate();
                    open   = Application.OpenForms["frmStandardRate"] as frmStandardRate;
                    break;

                case "Tax":
                    if (spSettings.SettingsStatusCheck("Tax") == "Yes")
                    {
                        frmObj = new frmTax();
                        open   = Application.OpenForms["frmTax"] as frmTax;
                    }
                    break;

                case "Currency":
                    if (spSettings.SettingsStatusCheck("MultiCurrency") == "Yes")
                    {
                        frmObj = new frmCurrency();
                        open   = Application.OpenForms["frmCurrency"] as frmCurrency;
                    }
                    break;

                case "Exchange Rate":
                    frmObj = new frmExchangeRate();
                    open   = Application.OpenForms["frmExchangeRate"] as frmExchangeRate;
                    break;

                case "Service Category":
                    frmObj = new frmServiceCategory();
                    open   = Application.OpenForms["frmServiceCategory"] as frmServiceCategory;
                    break;

                case "Services":
                    frmObj = new frmServices();
                    open   = Application.OpenForms["frmServices"] as frmServices;
                    break;

                case "Voucher Type":
                    frmObj = new frmVoucherType();
                    open   = Application.OpenForms["frmVoucherType"] as frmVoucherType;
                    break;

                case "Area":
                    frmObj = new frmArea();
                    open   = Application.OpenForms["frmArea"] as frmArea;
                    break;

                case "Route":
                    frmObj = new frmRoute();
                    open   = Application.OpenForms["frmRoute"] as frmRoute;
                    break;

                case "Counter":
                    frmObj = new frmCounter();
                    open   = Application.OpenForms["frmCounter"] as frmCounter;
                    break;

                case "Product Register":
                    frmObj = new frmProductRegister();
                    open   = Application.OpenForms["frmProductRegister"] as frmProductRegister;
                    break;

                case "Salesman":
                    frmObj = new frmSalesman();
                    open   = Application.OpenForms["frmSalesman"] as frmSalesman;
                    break;

                case "Contra Register":
                    frmObj = new frmContraRegister();
                    open   = Application.OpenForms["frmContraRegister"] as frmContraRegister;
                    break;

                case "Payment Register":
                    frmObj = new frmPaymentRegister();
                    open   = Application.OpenForms["frmPaymentRegister"] as frmPaymentRegister;
                    break;

                case "Receipt Register":
                    frmObj = new frmReceiptRegister();
                    open   = Application.OpenForms["frmReceiptRegister"] as frmReceiptRegister;
                    break;

                case "Journal Register":
                    frmObj = new frmJournalRegister();
                    open   = Application.OpenForms["frmJournalRegister"] as frmJournalRegister;
                    break;

                case "PDC Payable Register":
                    frmObj = new frmPDCPayableRegister();
                    open   = Application.OpenForms["frmPDCPayableRegister"] as frmPDCPayableRegister;
                    break;

                case "PDC Receivable Register":
                    frmObj = new frmPDCReceivableRegister();
                    open   = Application.OpenForms["frmPDCReceivableRegister"] as frmPDCReceivableRegister;
                    break;

                case "PDC Clearance Register":
                    frmObj = new frmPdcClearanceRegister();
                    open   = Application.OpenForms["frmPdcClearanceRegister"] as frmPdcClearanceRegister;
                    break;

                case "Purchase Order Register":
                    frmObj = new frmPurchaseOrderRegister();
                    open   = Application.OpenForms["frmPurchaseOrderRegister"] as frmPurchaseOrderRegister;
                    break;

                case "Material Receipt Register":
                    frmObj = new frmMaterialReceiptRegister();
                    open   = Application.OpenForms["frmMaterialReceiptRegister"] as frmMaterialReceiptRegister;
                    break;

                case "Rejection Out Register":
                    frmObj = new frmRejectionOutRegister();
                    open   = Application.OpenForms["frmRejectionOutRegister"] as frmRejectionOutRegister;
                    break;

                case "Purchase Invoice Register":
                    frmObj = new frmPurchaseInvoiceRegister();
                    open   = Application.OpenForms["frmPurchaseInvoiceRegister"] as frmPurchaseInvoiceRegister;
                    break;

                case "Purchase Return Register":
                    frmObj = new frmPurchaseReturnRegister();
                    open   = Application.OpenForms["frmPurchaseReturnRegister"] as frmPurchaseReturnRegister;
                    break;

                case "Sales Quotation Register":
                    frmObj = new frmSalesQuotationRegister();
                    open   = Application.OpenForms["frmSalesQuotationRegister"] as frmSalesQuotationRegister;
                    break;

                case "Sales Order Register":
                    frmObj = new frmSalesOrderRegister();
                    open   = Application.OpenForms["frmSalesOrderRegister"] as frmSalesOrderRegister;
                    break;

                case "Delivery Note Register":
                    frmObj = new frmDeliveryNoteRegister();
                    open   = Application.OpenForms["frmDeliveryNoteRegister"] as frmDeliveryNoteRegister;
                    break;

                case "Rejection In Register":
                    frmObj = new frmRejectionInRegister();
                    open   = Application.OpenForms["frmRejectionInRegister"] as frmRejectionInRegister;
                    break;

                case "Sales Invoice Register":
                    frmObj = new frmSalesInvoiceRegister();
                    open   = Application.OpenForms["frmSalesInvoiceRegister"] as frmSalesInvoiceRegister;
                    break;

                case "Sales Return Register":
                    frmObj = new frmSalesReturnRegister();
                    open   = Application.OpenForms["frmSalesReturnRegister"] as frmSalesReturnRegister;
                    break;

                case "Physical Stock Register":
                    frmObj = new frmPhysicalStockRegister();
                    open   = Application.OpenForms["frmPhysicalStockRegister"] as frmPhysicalStockRegister;
                    break;

                case "Service Voucher Register":
                    frmObj = new frmServiceVoucherRegister();
                    open   = Application.OpenForms["frmServiceVoucherRegister"] as frmServiceVoucherRegister;
                    break;

                case "Credit Note Register":
                    frmObj = new frmCreditNoteRegister();
                    open   = Application.OpenForms["frmCreditNoteRegister"] as frmCreditNoteRegister;
                    break;

                case "Debit Note Register":
                    frmObj = new frmDebitNoteRegister();
                    open   = Application.OpenForms["frmDebitNoteRegister"] as frmDebitNoteRegister;
                    break;

                case "Stock Journal Register":
                    frmObj = new frmStockJournalRegister();
                    open   = Application.OpenForms["frmStockJournalRegister"] as frmStockJournalRegister;
                    break;

                case "Designation":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmDesignation();
                        open   = Application.OpenForms["frmDesignation"] as frmDesignation;
                    }
                    break;

                case "Pay Head":
                {
                    frmObj = new frmPayHead();
                    open   = Application.OpenForms["frmPayHead"] as frmPayHead;
                }
                break;

                case "Salary Package Creation":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmSalaryPackageCreation();
                        open   = Application.OpenForms["frmSalaryPackageCreation"] as frmSalaryPackageCreation;
                    }
                    break;

                case "Salary Package Register":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmSalaryPackageRegister();
                        open   = Application.OpenForms["frmSalaryPackageRegister"] as frmSalaryPackageRegister;
                    }
                    break;

                case "Employee Creation":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmEmployeeCreation();
                        open   = Application.OpenForms["frmEmployeeCreation"] as frmEmployeeCreation;
                    }
                    break;

                case "Employee Register":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmEmployeeRegister();
                        open   = Application.OpenForms["frmEmployeeRegister"] as frmEmployeeRegister;
                    }
                    break;

                case "Holiday Settings":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmHolydaySettings();
                        open   = Application.OpenForms["frmHolydaySettings"] as frmHolydaySettings;
                    }
                    break;

                case "Monthly Salary Settings":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmMonthlySalarySettings();
                        open   = Application.OpenForms["frmMonthlySalarySettings"] as frmMonthlySalarySettings;
                    }
                    break;

                case "Attendance":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmAttendance();
                        open   = Application.OpenForms["frmAttendance"] as frmAttendance;
                    }
                    break;

                case "Advance Payment":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmAdvancePayment();
                        open   = Application.OpenForms["frmAdvancePayment"] as frmAdvancePayment;
                    }
                    break;

                case "Advance Register":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmAdvanceRegister();
                        open   = Application.OpenForms["frmAdvanceRegister"] as frmAdvanceRegister;
                    }
                    break;

                case "Bonus Deduction":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmBonusDeduction();
                        open   = Application.OpenForms["frmBonusDeduction"] as frmBonusDeduction;
                    }
                    break;

                case "Bonus Deduction Register":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmBonusDeductionRegister();
                        open   = Application.OpenForms["frmBonusDeductionRegister"] as frmBonusDeductionRegister;
                    }
                    break;

                case "Monthly Salary Voucher":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmMonthlySalaryVoucher();
                        open   = Application.OpenForms["frmMonthlySalaryVoucher"] as frmMonthlySalaryVoucher;
                    }
                    break;

                case "Monthly Salary Register":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmMonthlySalaryRegister();
                        open   = Application.OpenForms["frmMonthlySalaryRegister"] as frmMonthlySalaryRegister;
                    }
                    break;

                case "Daily Salary Voucher":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmDailySalaryVoucher();
                        open   = Application.OpenForms["frmDailySalaryVoucher"] as frmDailySalaryVoucher;
                    }
                    break;

                case "Daily Salary Register":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmDailySalaryRegister();
                        open   = Application.OpenForms["frmDailySalaryRegister"] as frmDailySalaryRegister;
                    }
                    break;

                case "Pay Slip":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmPaySlip();
                        open   = Application.OpenForms["frmPaySlip"] as frmPaySlip;
                    }
                    break;

                case "Budget":
                    if (spSettings.SettingsStatusCheck("Budget") == "Yes")
                    {
                        frmObj = new frmBudget();
                        open   = Application.OpenForms["frmBudget"] as frmBudget;
                    }
                    break;

                case "Budget Variance":
                    if (spSettings.SettingsStatusCheck("Budget") == "Yes")
                    {
                        frmObj = new frmBudgetVariance();
                        open   = Application.OpenForms["frmBudgetVariance"] as frmBudgetVariance;
                    }
                    break;

                case "Change Current Date":
                    frmObj = new frmChangeCurrentDate();
                    open   = Application.OpenForms["frmChangeCurrentDate"] as frmChangeCurrentDate;
                    break;

                case "Settings":
                    frmObj = new frmSettings();
                    open   = Application.OpenForms["frmSettings"] as frmSettings;
                    break;

                case "Role":
                    frmObj = new frmRole();
                    open   = Application.OpenForms["frmRole"] as frmRole;
                    break;

                case "Role Privilege Settings":
                    frmObj = new frmRolePrivilegeSettings();
                    open   = Application.OpenForms["frmRolePrivilegeSettings"] as frmRolePrivilegeSettings;
                    break;

                case "User Creation":
                    frmObj = new frmUserCreation();
                    open   = Application.OpenForms["frmUserCreation"] as frmUserCreation;
                    break;

                case "Change Password":
                    frmObj = new frmChangePassword();
                    open   = Application.OpenForms["frmChangePassword"] as frmChangePassword;
                    break;

                case "New Financial Year":
                    frmObj = new frmNewFinancialYear();
                    open   = Application.OpenForms["frmNewFinancialYear"] as frmNewFinancialYear;
                    break;

                case "Change Financial Year":
                    frmObj = new frmChangeFinancialYear();
                    open   = Application.OpenForms["frmChangeFinancialYear"] as frmChangeFinancialYear;
                    break;

                case "Barcode Settings":
                    frmObj = new frmBarcodeSettings();
                    open   = Application.OpenForms["frmBarcodeSettings"] as frmBarcodeSettings;
                    break;

                case "Barcode Printing":
                    frmObj = new frmBarcodePrinting();
                    open   = Application.OpenForms["frmBarcodePrinting"] as frmBarcodePrinting;
                    break;

                case "Suffix Prefix Settings":
                    frmObj = new frmSuffixPrefixSettings();
                    open   = Application.OpenForms["frmSuffixPrefixSettings"] as frmSuffixPrefixSettings;
                    break;

                case "Change Product Tax":
                    frmObj = new frmChangeProductTax();
                    open   = Application.OpenForms["frmChangeProductTax"] as frmChangeProductTax;
                    break;

                case "Product Search":
                    frmObj = new frmProductSearch();
                    open   = Application.OpenForms["frmProductSearch"] as frmProductSearch;
                    break;

                case "Voucher Search":
                    frmObj = new frmVoucherSearch();
                    open   = Application.OpenForms["frmVoucherSearch"] as frmVoucherSearch;
                    break;

                case "Voucher Wise Product Search":
                    frmObj = new frmVoucherWiseProductSearch();
                    open   = Application.OpenForms["frmVoucherWiseProductSearch"] as frmVoucherWiseProductSearch;
                    break;

                case "Personal Reminder":
                    frmObj = new frmPersonalReminder();
                    open   = Application.OpenForms["frmPersonalReminder"] as frmPersonalReminder;
                    break;

                case "Overdue Purchase Order":
                    frmObj = new frmOverduePurchaseOrder();
                    open   = Application.OpenForms["frmOverduePurchaseOrder"] as frmOverduePurchaseOrder;
                    break;

                case "Overdue Sales Order":
                    frmObj = new frmOverdueSalesOrder();
                    open   = Application.OpenForms["frmOverdueSalesOrder"] as frmOverdueSalesOrder;
                    break;

                case "Short Expiry":
                    frmObj = new frmShortExpiry();
                    open   = Application.OpenForms["frmShortExpiry"] as frmShortExpiry;
                    break;

                case "Stock":
                    frmObj = new frmStock();
                    open   = Application.OpenForms["frmStock"] as frmStock;
                    break;

                case "Trial Balance":
                    frmObj = new frmTrialBalance();
                    open   = Application.OpenForms["frmTrialBalance"] as frmTrialBalance;
                    break;

                case "Balance Sheet":
                    frmObj = new frmBalanceSheet();
                    open   = Application.OpenForms["frmBalanceSheet"] as frmBalanceSheet;
                    break;

                case "Profit and Loss":
                    frmObj = new frmProfitAndLoss();
                    open   = Application.OpenForms["frmProfitAndLoss"] as frmProfitAndLoss;
                    break;

                case "Cash Flow":
                    frmObj = new frmCashFlow();
                    open   = Application.OpenForms["frmCashFlow"] as frmCashFlow;
                    break;

                case "Fund Flow":
                    frmObj = new frmFundFlow();
                    open   = Application.OpenForms["frmFundFlow"] as frmFundFlow;
                    break;

                case "Chart of Account":
                    frmObj = new frmChartOfAccount();
                    open   = Application.OpenForms["frmChartOfAccount"] as frmChartOfAccount;
                    break;

                case "Contra Report":
                    frmObj = new frmContraReport();
                    open   = Application.OpenForms["frmContraReport"] as frmContraReport;
                    break;

                case "Payment Report":
                    frmObj = new frmPaymentReport();
                    open   = Application.OpenForms["frmPaymentReport"] as frmPaymentReport;
                    break;

                case "Receipt Report":
                    frmObj = new frmReceiptReport();
                    open   = Application.OpenForms["frmReceiptReport"] as frmReceiptReport;
                    break;

                case "Journal Report":
                    frmObj = new frmJournalReport();
                    open   = Application.OpenForms["frmJournalReport"] as frmJournalReport;
                    break;

                case "PDC Payable Report":
                    frmObj = new frmPDCPayableReport();
                    open   = Application.OpenForms["frmPDCPayableReport"] as frmPDCPayableReport;
                    break;

                case "PDC Receivable Report":
                    frmObj = new frmPDCRecievableReport();
                    open   = Application.OpenForms["frmPDCRecievableReport"] as frmPDCRecievableReport;
                    break;

                case "PDC Clearance Report":
                    frmObj = new frmPDCClearanceReport();
                    open   = Application.OpenForms["frmPDCClearanceReport"] as frmPDCClearanceReport;
                    break;

                case "Purchase Order Report":
                    frmObj = new frmPurchaseOrderReport();
                    open   = Application.OpenForms["frmPurchaseOrderReport"] as frmPurchaseOrderReport;
                    break;

                case "Material Receipt Report":
                    frmObj = new frmMaterialReceiptReport();
                    open   = Application.OpenForms["frmMaterialReceiptReport"] as frmMaterialReceiptReport;
                    break;

                case "Rejection Out Report":
                    frmObj = new frmRejectionOutReport();
                    open   = Application.OpenForms["frmRejectionOutReport"] as frmRejectionOutReport;
                    break;

                case "Purchase Invoice Report":
                    frmObj = new frmPurchaseReport();
                    open   = Application.OpenForms["frmPurchaseReport"] as frmPurchaseReport;
                    break;

                case "Purchase Return Report":
                    frmObj = new frmPurchaseReturnReport();
                    open   = Application.OpenForms["frmPurchaseReturnReport"] as frmPurchaseReturnReport;
                    break;

                case "Sales Quotation Report":
                    frmObj = new frmSalesQuotationReport();
                    open   = Application.OpenForms["frmSalesQuotationReport"] as frmSalesQuotationReport;
                    break;

                case "Sales Order Report":
                    frmObj = new frmSalesOrderReport();
                    open   = Application.OpenForms["frmSalesOrderReport"] as frmSalesOrderReport;
                    break;

                case "Delivery Note Report":
                    frmObj = new frmDeliveryNoteReport();
                    open   = Application.OpenForms["frmDeliveryNoteReport"] as frmDeliveryNoteReport;
                    break;

                case "Rejection In Report":
                    frmObj = new frmRejectionInReport();
                    open   = Application.OpenForms["frmRejectionInReport"] as frmRejectionInReport;
                    break;

                case "Sales Invoice Report":
                    frmObj = new frmSalesReport();
                    open   = Application.OpenForms["frmSalesReport"] as frmSalesReport;
                    break;

                case "Sales Return Report":
                    frmObj = new frmSalesReturnReport();
                    open   = Application.OpenForms["frmSalesReturnReport"] as frmSalesReturnReport;
                    break;

                case "Physical Stock Report":
                    frmObj = new frmPhysicalStockReport();
                    open   = Application.OpenForms["frmPhysicalStockReport"] as frmPhysicalStockReport;
                    break;

                case "Service Report":
                    frmObj = new frmServiceReport();
                    open   = Application.OpenForms["frmServiceReport"] as frmServiceReport;
                    break;

                case "Credit Note Report":
                    frmObj = new frmCreditNoteReport();
                    open   = Application.OpenForms["frmCreditNoteReport"] as frmCreditNoteReport;
                    break;

                case "Debit Note Report":
                    frmObj = new frmDebitNoteReport();
                    open   = Application.OpenForms["frmDebitNoteReport"] as frmDebitNoteReport;
                    break;

                case "Stock Journal Report":
                    frmObj = new frmStockJournelReport();
                    open   = Application.OpenForms["frmStockJournelReport"] as frmStockJournelReport;
                    break;

                case "Employee Report":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmEmployeeReport();
                        open   = Application.OpenForms["frmEmployeeReport"] as frmEmployeeReport;
                    }
                    break;

                case "Daily Attendance Report":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmDailyAttendanceReport();
                        open   = Application.OpenForms["frmDailyAttendanceReport"] as frmDailyAttendanceReport;
                    }
                    break;

                case "Monthly Attendance Report":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmMonthlyAttendanceReport();
                        open   = Application.OpenForms["frmMonthlyAttendanceReport"] as frmMonthlyAttendanceReport;
                    }
                    break;

                case "Daily Salary Report":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmDailySalaryReport();
                        open   = Application.OpenForms["frmDailySalaryReport"] as frmDailySalaryReport;
                    }
                    break;

                case "Monthly Salary Report":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmMonthlySalaryReport();
                        open   = Application.OpenForms["frmMonthlySalaryReport"] as frmMonthlySalaryReport;
                    }
                    break;

                case "Payhead Report":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmPayHeadReport();
                        open   = Application.OpenForms["frmPayHeadReport"] as frmPayHeadReport;
                    }
                    break;

                case "Salary Package Report":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmSalaryPackageReport();
                        open   = Application.OpenForms["frmSalaryPackageReport"] as frmSalaryPackageReport;
                    }
                    break;

                case "Advance Payment Report":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmAdvancePaymentReport();
                        open   = Application.OpenForms["frmAdvancePaymentReport"] as frmAdvancePaymentReport;
                    }
                    break;

                case "Bonus Deduction Report":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmBonusDeductionReport();
                        open   = Application.OpenForms["frmBonusDeductionReport"] as frmBonusDeductionReport;
                    }
                    break;

                case "Employee Address Book Report":
                    if (spSettings.SettingsStatusCheck("Payroll") == "Yes")
                    {
                        frmObj = new frmEmployeeAddressBook();
                        open   = Application.OpenForms["frmEmployeeAddressBook"] as frmEmployeeAddressBook;
                    }
                    break;

                case "Day Book":
                    frmObj = new frmDayBook();
                    open   = Application.OpenForms["frmDayBook"] as frmDayBook;
                    break;

                case "Cash/Bank Book":
                    frmObj = new frmCashBankBookReport();
                    open   = Application.OpenForms["frmCashBankBookReport"] as frmCashBankBookReport;
                    break;

                case "Account Groupwise Report":
                    frmObj = new frmAccountGroupwiseReport();
                    open   = Application.OpenForms["frmAccountGroupwiseReport"] as frmAccountGroupwiseReport;
                    break;

                case "Account Ledger Report":
                    frmObj = new frmAccountLedgerReport();
                    open   = Application.OpenForms["frmAccountLedgerReport"] as frmAccountLedgerReport;
                    break;

                case "Outstanding Report":
                    frmObj = new frmOutstandingReport();
                    open   = Application.OpenForms["frmOutstandingReport"] as frmOutstandingReport;
                    break;

                case "Ageing Report":
                    frmObj = new frmAgeingReport();
                    open   = Application.OpenForms["frmAgeingReport"] as frmAgeingReport;
                    break;

                case "Party's Address Book":
                    frmObj = new frmPartyAddressBook();
                    open   = Application.OpenForms["frmPartyAddressBook"] as frmPartyAddressBook;
                    break;

                case "Stock Report":
                    frmObj = new frmStockReport();
                    open   = Application.OpenForms["frmStockReport"] as frmStockReport;
                    break;

                case "Short Expiry Report":
                    frmObj = new frmShortExpiryReport();
                    open   = Application.OpenForms["frmShortExpiryReport"] as frmShortExpiryReport;
                    break;

                case "Product Statistics":
                    frmObj = new frmProductStatistics();
                    open   = Application.OpenForms["frmProductStatistics"] as frmProductStatistics;
                    break;

                case "Price List Report":
                    frmObj = new frmPriceListReport();
                    open   = Application.OpenForms["frmPriceListReport"] as frmPriceListReport;
                    break;

                case "Tax Report":
                    frmObj = new frmTaxReport();
                    open   = Application.OpenForms["frmTaxReport"] as frmTaxReport;
                    break;

                case "VAT Report":
                    frmObj = new frmVatReturnReport();
                    open   = Application.OpenForms["frmVatReturnReport"] as frmVatReturnReport;
                    break;

                case "Cheque Report":
                    frmObj = new frmChequeReport();
                    open   = Application.OpenForms["frmChequeReport"] as frmChequeReport;
                    break;

                case "Free Sale Report":
                    frmObj = new frmFreeSaleReport();
                    open   = Application.OpenForms["frmFreeSaleReport"] as frmFreeSaleReport;
                    break;

                case "Product Vs Batch Report":
                    frmObj = new frmProductVsBatchReport();
                    open   = Application.OpenForms["frmProductVsBatchReport"] as frmProductVsBatchReport;
                    break;

                case "Customer":
                    frmObj = new frmCustomer();
                    open   = Application.OpenForms["frmCustomer"] as frmCustomer;
                    break;

                case "Supplier":
                    frmObj = new frmSupplier();
                    open   = Application.OpenForms["frmSupplier"] as frmSupplier;
                    break;
                }
                if (frmObj != null)
                {
                    if (open == null)
                    {
                        frmObj.MdiParent = formMDI.MDIObj;
                        frmObj.Show();
                    }
                    else
                    {
                        open.Activate();
                        if (open.WindowState == FormWindowState.Minimized)
                        {
                            open.WindowState = FormWindowState.Normal;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("QL:4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }