Beispiel #1
0
        public void InsertInvoice(ASCAmount ascamount, string UserName, string AscId, string BranchId, string regionid, int Month, int Year, int iscarryforward)
        {                                                               // needs to replace and calls once time
            InvoiceAmount objinvoice = new InvoiceAmount();
            InvoiceAmount invoice    = objinvoice.BindInvoiveAmount(1); // change the value 1 to other if amount will change in future


            //Month = DateTime.Now.Month - 1;
            //if (Month == 0)
            //{
            //    Month = 12;
            //}

            try
            {
                SqlParameter[] sqlParamI =
                {
                    new SqlParameter("@ascid",                                          AscId),
                    new SqlParameter("@ASCUserID",                                      UserName),
                    new SqlParameter("@regionid",                                       regionid),
                    new SqlParameter("@BranchId",                                       BranchId),
                    new SqlParameter("@Month",                                          Month),
                    new SqlParameter("@Year",                                           Year),

                    //new SqlParameter("@UserName",UserName), sry amount replace as total complaint

                    new SqlParameter("@Localwhc18Repr",                                 ascamount.txtLWH18),
                    new SqlParameter("@LocalWHC24Repr",                                 ascamount.txtLWH24),
                    new SqlParameter("@LocalWHC48Repr",                                 ascamount.txtLWH72),
                    new SqlParameter("@LocalWHC72Repr",                                 ascamount.txtLWH120),
                    new SqlParameter("@LocalWHC120Repr",                                ascamount.txtLWH72120),
                    new SqlParameter("@LocalWHC121Repr",                                ascamount.txtLWHgreater120),


                    new SqlParameter("@LocalWOHC18Repr",                                ascamount.txtLWOH18),
                    new SqlParameter("@LocalWOHC24Repr",                                ascamount.txtLWOH24),
                    new SqlParameter("@LocalWOHC48Repr",                                ascamount.txtLWOH72),
                    new SqlParameter("@LocalWOHC72Repr",                                ascamount.txtLWOH120),
                    new SqlParameter("@LocalWOHC120Repr",                               ascamount.txtLWOH72120),
                    new SqlParameter("@LocalWOHC121Repr",                               ascamount.txtLWOHgreater120),

                    //

                    new SqlParameter("@OUTWHC18Repr",                                   ascamount.txtOWH18),
                    new SqlParameter("@OUTWHC24Repr",                                   ascamount.txtOWH24),
                    new SqlParameter("@OUTWHC48Repr",                                   ascamount.txtOWH72),
                    new SqlParameter("@OUTWHC72Repr",                                   ascamount.txtOWH120),
                    new SqlParameter("@OUTWHC120Repr",                                  ascamount.txtOWH72120),
                    new SqlParameter("@OUTWHC121Repr",                                  ascamount.txtOWHgreater120),


                    new SqlParameter("@OUTWOHC18Repr",                                  ascamount.txtOWOH18),
                    new SqlParameter("@OUTWOHC24Repr",                                  ascamount.txtOWOH24),
                    new SqlParameter("@OUTWOHC48Repr",                                  ascamount.txtOWOH72),
                    new SqlParameter("@OUTWOHC72Repr",                                  ascamount.txtOWOH120),
                    new SqlParameter("@OUTWOHC120Repr",                                 ascamount.txtOWOH72120),
                    new SqlParameter("@OUTWOHC121Repr",                                 ascamount.txtOWOHgreater120),

                    /////


                    // repair
                    new SqlParameter("@LocalWHC18Rep",                                  ascamount.lblLWHURep18),
                    new SqlParameter("@LocalWHC24Rep",                                  ascamount.lblLWHURep24),
                    new SqlParameter("@LocalWHC48Rep",                                  ascamount.lblLWHURep72),
                    new SqlParameter("@LocalWHC72Rep",                                  ascamount.lblLWHURep120),
                    new SqlParameter("@LocalWHC120Rep",                                 ascamount.lblLWHURep72120),
                    new SqlParameter("@LocalWHC121Rep",                                 ascamount.lblLWHURepgreater120),



                    new SqlParameter("@LocalWOHC18Rep",                                 ascamount.lblLWOHURep18),
                    new SqlParameter("@LocalWOHC24Rep",                                 ascamount.lblLWOHURep24),
                    new SqlParameter("@LocalWOHC48Rep",                                 ascamount.lblLWOHURep72),
                    new SqlParameter("@LocalWOHC72Rep",                                 ascamount.lblLWOHURep120),
                    new SqlParameter("@LocalWOHC120Rep",                                ascamount.lblLWOHURep72120),
                    new SqlParameter("@LocalWOHC121Rep",                                ascamount.lblLWOHURepgreater120),


                    new SqlParameter("@OUTWHC18Rep",                                    ascamount.lblOWHURep18),
                    new SqlParameter("@OUTWHC24Rep",                                    ascamount.lblOWHURep24),
                    new SqlParameter("@OUTWHC48Rep",                                    ascamount.lblOWHURep72),
                    new SqlParameter("@OUTWHC72Rep",                                    ascamount.lblOWHURep120),
                    new SqlParameter("@OUTWHC120Rep",                                   ascamount.lblOWHURep72120),
                    new SqlParameter("@OUTWHC121Rep",                                   ascamount.lblOWHURepgreater120),



                    new SqlParameter("@OUTWOHC18Rep",                                   ascamount.lblOWOHURep18),
                    new SqlParameter("@OUTWOHC24Rep",                                   ascamount.lblOWOHURep24),
                    new SqlParameter("@OUTWOHC48Rep",                                   ascamount.lblOWOHURep72),
                    new SqlParameter("@OUTWOHC72Rep",                                   ascamount.lblOWOHURep120),
                    new SqlParameter("@OUTWOHC120Rep",                                  ascamount.lblOWOHURep72120),
                    new SqlParameter("@OUTWOHC121Rep",                                  ascamount.lblOWOHURepgreater120),



                    //
                    new SqlParameter("@RepairandReplacementLocalInstutional",           ascamount.RepairandReplacementLocalInstutional),
                    new SqlParameter("@RepairandReplacementOutstationInstitutional",    ascamount.RepairandReplacementOutstationInstitutional),
                    new SqlParameter("@LocalLogisticsCharges",                          "0"),
                    new SqlParameter("@OutstationLogisticsCharges",                     "0"),



                    // amount to be paid

                    new SqlParameter("@LocalWHC18ReprAmt",                              invoice.lblLWHU18),
                    new SqlParameter("@LocalWHC24ReprAmt",                              invoice.lblLWHU24),
                    new SqlParameter("@LocalWHC48ReprAmt",                              invoice.lblLWHU72),
                    new SqlParameter("@LocalWHC72ReprAmt",                              invoice.lblLWHU120),
                    new SqlParameter("@LocalWHC120ReprAmt",                             invoice.lblLWHU72120),
                    new SqlParameter("@LocalWHC121ReprAmt",                             invoice.lblLWHUgreater120),


                    new SqlParameter("@LocalWOHC18ReprAmt",                             invoice.lblLWOHU18),
                    new SqlParameter("@LocalWOHC24ReprAmt",                             invoice.lblLWOHU24),
                    new SqlParameter("@LocalWOHC48ReprAmt",                             invoice.lblLWOHU72),
                    new SqlParameter("@LocalWOHC72ReprAmt",                             invoice.lblLWOHU120),
                    new SqlParameter("@LocalWOHC120ReprAmt",                            invoice.lblLWOHU72120),
                    new SqlParameter("@LocalWOHC121ReprAmt",                            invoice.lblLWOHUgreater120),



                    new SqlParameter("@OUTWHC18ReprAmt",                                invoice.lblOWHU18),
                    new SqlParameter("@OUTWHC24ReprAmt",                                invoice.lblOWHU24),
                    new SqlParameter("@OUTWHC48ReprAmt",                                invoice.lblOWHU72),
                    new SqlParameter("@OUTWHC72ReprAmt",                                invoice.lblOWHU120),
                    new SqlParameter("@OUTWHC120ReprAmt",                               invoice.lblOWHU72120),
                    new SqlParameter("@OUTWHC121ReprAmt",                               invoice.lblOWHUgreater120),


                    new SqlParameter("@OUTWOHC18ReprAmt",                               invoice.lblOWOHU18),
                    new SqlParameter("@OUTWOHC24ReprAmt",                               invoice.lblOWOHU24),
                    new SqlParameter("@OUTWOHC48ReprAmt",                               invoice.lblOWOHU72),
                    new SqlParameter("@OUTWOHC72ReprAmt",                               invoice.lblOWOHU120),
                    new SqlParameter("@OUTWOHC120ReprAmt",                              invoice.lblOWOHU72120),
                    new SqlParameter("@OUTWOHC121ReprAmt",                              invoice.lblOWOHUgreater120),

                    // replacement

                    new SqlParameter("@LocalWHC18RepAmt",                               invoice.lblLWHARep18),
                    new SqlParameter("@LocalWHC24RepAmt",                               invoice.lblLWHARep24),
                    new SqlParameter("@LocalWHC48RepAmt",                               invoice.lblLWHARep72),
                    new SqlParameter("@LocalWHC72RepAmt",                               invoice.lblLWHARep120),
                    new SqlParameter("@LocalWHC120RepAmt",                              invoice.lblLWHARep72120),
                    new SqlParameter("@LocalWHC121RepAmt",                              invoice.lblLWHARepgreater120),


                    new SqlParameter("@LocalWOHC18RepAmt",                              invoice.lblLWOHARep18),
                    new SqlParameter("@LocalWOHC24RepAmt",                              invoice.lblLWOHARep24),
                    new SqlParameter("@LocalWOHC48RepAmt",                              invoice.lblLWOHARep72),
                    new SqlParameter("@LocalWOHC72RepAmt",                              invoice.lblLWOHARep120),
                    new SqlParameter("@LocalWOHC120RepAmt",                             invoice.lblLWOHARep72120),
                    new SqlParameter("@LocalWOHC121RepAmt",                             invoice.lblLWOHARepgreater120),



                    new SqlParameter("@OUTWHC18RepAmt",                                 invoice.lblOWHARep18),
                    new SqlParameter("@OUTWHC24RepAmt",                                 invoice.lblOWHARep24),
                    new SqlParameter("@OUTWHC48RepAmt",                                 invoice.lblOWHARep72),
                    new SqlParameter("@OUTWHC72RepAmt",                                 invoice.lblOWHARep120),
                    new SqlParameter("@OUTWHC120RepAmt",                                invoice.lblOWHARep72120),
                    new SqlParameter("@OUTWHC121RepAmt",                                invoice.lblOWHARepgreater120),

                    new SqlParameter("@OUTWOHC18RepAmt",                                invoice.lblOWOHARep18),
                    new SqlParameter("@OUTWOHC24RepAmt",                                invoice.lblOWOHARep24),
                    new SqlParameter("@OUTWOHC48RepAmt",                                invoice.lblOWOHARep72),
                    new SqlParameter("@OUTWOHC72RepAmt",                                invoice.lblOWOHARep120),
                    new SqlParameter("@OUTWOHC120RepAmt",                               invoice.lblOWOHARep72120),
                    new SqlParameter("@OUTWOHC121RepAmt",                               invoice.lblOWOHARepgreater120),

                    //

                    new SqlParameter("@RepairandReplacementLocalInstutionalAmt",        invoice.lblRepLoU),
                    new SqlParameter("@RepairandReplacementOutstationInstitutionalAmt", invoice.lblRepOoA),
                    new SqlParameter("@LocalLogisticsChargesAmt",                       "0"),
                    new SqlParameter("@OutstationLogisticsChargesAmt",                  "0"),

                    new SqlParameter("@Quantity",                                       ascamount.lblQuanityfd),
                    new SqlParameter("@UnitPrice",                                      ascamount.lblfdUnitPrice),
                    new SqlParameter("@Amount",                                         ascamount.Amount),
                    new SqlParameter("@iscarryforward",                                 iscarryforward),
                }; //usp_fanpaymentcalulation
                int i = objSql.ExecuteNonQuery(CommandType.StoredProcedure, "usp_fanpaymentcalulation", sqlParamI);
            }
            catch (Exception ex)
            {
                // also track to save in table
                Util.WriteToFile("exception msg " + ex.Message + " Time  " + DateTime.Now + " AscId: " + AscId + "BranchId " + BranchId + "regionid " + regionid + "Month " + Month + "Year " + Year);
            }
        }
Beispiel #2
0
        protected void calculate(string Username, int month, int year, string RegionId, string BranchId, string AscId, int carryforward)
        {
            try
            {
                CommonClass common = new API.CommonClass();
                DataSet     ds = null; DataSet instutionalds = null; DataSet invoiceDetails = null;

                if (carryforward == 0) //current month
                {
                    ds             = common.GenenerateInvoiceForFanSC(Username, month, year, "usp_GenenerateInvoiceForFanSC", carryforward);
                    instutionalds  = InstutionalDetails(Username, month, year, "GenerateInvoiceInstitutionalFan", carryforward);
                    invoiceDetails = common.GetInvoiceDetails(year, month, AscId, BranchId, RegionId, Username, "GenerateInvoiceFan");
                }


                else if (carryforward == 1) // old month
                {
                    ds            = common.GenenerateInvoiceForFanSC(Username, month, year, "usp_GenenerateInvoiceForFanSC", carryforward);
                    instutionalds = InstutionalDetails(Username, month, year, "GenerateInvoiceInstitutionalFan", carryforward);
                }



                ASCAmount objASC = new ASCAmount();
                if (ds != null && instutionalds != null)
                {
                    int countL = 0, countO = 0;
                    foreach (DataRow drs in instutionalds.Tables[0].Rows)
                    {
                        if (drs["Activity"].ToString().Equals("L"))
                        {
                            countL = countL + 1;
                        }

                        if (drs["Activity"].ToString().Equals("O"))
                        {
                            countO = countO + 1;
                        }
                    }

                    objASC.RepairandReplacementLocalInstutional        = countL.ToString();
                    objASC.RepairandReplacementOutstationInstitutional = countO.ToString();

                    //complaint count
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        objASC.txtLWH18  = ds.Tables[0].Rows[0]["<=18 Hours"].ToString();
                        objASC.txtLWH24  = ds.Tables[0].Rows[0]["18<Hours<=24"].ToString();
                        objASC.txtLWH72  = ds.Tables[0].Rows[0]["24<Hours<=48"].ToString();
                        objASC.txtLWH120 = ds.Tables[0].Rows[0]["48<Hours>=72"].ToString();

                        objASC.txtLWH72120      = ds.Tables[0].Rows[0]["72<Hours>=120"].ToString();
                        objASC.txtLWHgreater120 = ds.Tables[0].Rows[0][">120Hours"].ToString();

                        //

                        objASC.txtLWOH18  = ds.Tables[0].Rows[1]["<=18 Hours"].ToString();
                        objASC.txtLWOH24  = ds.Tables[0].Rows[1]["18<Hours<=24"].ToString();
                        objASC.txtLWOH72  = ds.Tables[0].Rows[1]["24<Hours<=48"].ToString();
                        objASC.txtLWOH120 = ds.Tables[0].Rows[1]["48<Hours>=72"].ToString();

                        objASC.txtLWOH72120      = ds.Tables[0].Rows[1]["72<Hours>=120"].ToString();
                        objASC.txtLWOHgreater120 = ds.Tables[0].Rows[1][">120Hours"].ToString();
                        //

                        objASC.txtOWH18         = ds.Tables[0].Rows[2]["<=18 Hours"].ToString();
                        objASC.txtOWH24         = ds.Tables[0].Rows[2]["18<Hours<=24"].ToString();
                        objASC.txtOWH72         = ds.Tables[0].Rows[2]["24<Hours<=48"].ToString();
                        objASC.txtOWH120        = ds.Tables[0].Rows[2]["48<Hours>=72"].ToString();
                        objASC.txtOWH72120      = ds.Tables[0].Rows[2]["72<Hours>=120"].ToString();
                        objASC.txtOWHgreater120 = ds.Tables[0].Rows[2][">120Hours"].ToString();
                        //

                        objASC.txtOWOH18         = ds.Tables[0].Rows[3]["<=18 Hours"].ToString();
                        objASC.txtOWOH24         = ds.Tables[0].Rows[3]["18<Hours<=24"].ToString();
                        objASC.txtOWOH72         = ds.Tables[0].Rows[3]["24<Hours<=48"].ToString();
                        objASC.txtOWOH120        = ds.Tables[0].Rows[3]["48<Hours>=72"].ToString();
                        objASC.txtOWOH72120      = ds.Tables[0].Rows[3]["72<Hours>=120"].ToString();
                        objASC.txtOWOHgreater120 = ds.Tables[0].Rows[3][">120Hours"].ToString();
                    }

                    ///////Replacement//////////////////////////////// complaint count

                    if (ds.Tables[1].Rows.Count > 0)
                    {
                        objASC.lblLWHURep18         = ds.Tables[1].Rows[0]["<=18 Hours"].ToString();
                        objASC.lblLWHURep24         = ds.Tables[1].Rows[0]["18<Hours<=24"].ToString();
                        objASC.lblLWHURep72         = ds.Tables[1].Rows[0]["24<Hours<=48"].ToString();
                        objASC.lblLWHURep120        = ds.Tables[1].Rows[0]["48<Hours>=72"].ToString();
                        objASC.lblLWHURep72120      = ds.Tables[1].Rows[0]["72<Hours>=120"].ToString();
                        objASC.lblLWHURepgreater120 = ds.Tables[1].Rows[0][">120Hours"].ToString();
                        //

                        objASC.lblLWOHURep18         = ds.Tables[1].Rows[1]["<=18 Hours"].ToString();
                        objASC.lblLWOHURep24         = ds.Tables[1].Rows[1]["18<Hours<=24"].ToString();
                        objASC.lblLWOHURep72         = ds.Tables[1].Rows[1]["24<Hours<=48"].ToString();
                        objASC.lblLWOHURep120        = ds.Tables[1].Rows[1]["48<Hours>=72"].ToString();
                        objASC.lblLWOHURep72120      = ds.Tables[1].Rows[1]["72<Hours>=120"].ToString();
                        objASC.lblLWOHURepgreater120 = ds.Tables[1].Rows[1][">120Hours"].ToString();
                        //

                        objASC.lblOWHURep18         = ds.Tables[1].Rows[2]["<=18 Hours"].ToString();
                        objASC.lblOWHURep24         = ds.Tables[1].Rows[2]["18<Hours<=24"].ToString();
                        objASC.lblOWHURep72         = ds.Tables[1].Rows[2]["24<Hours<=48"].ToString();
                        objASC.lblOWHURep120        = ds.Tables[1].Rows[2]["48<Hours>=72"].ToString();
                        objASC.lblOWHURep72120      = ds.Tables[1].Rows[2]["72<Hours>=120"].ToString();
                        objASC.lblOWHURepgreater120 = ds.Tables[1].Rows[2][">120Hours"].ToString();
                        //

                        objASC.lblOWOHURep18         = ds.Tables[1].Rows[3]["<=18 Hours"].ToString();
                        objASC.lblOWOHURep24         = ds.Tables[1].Rows[3]["18<Hours<=24"].ToString();
                        objASC.lblOWOHURep72         = ds.Tables[1].Rows[3]["24<Hours<=48"].ToString();
                        objASC.lblOWOHURep120        = ds.Tables[1].Rows[3]["48<Hours>=72"].ToString();
                        objASC.lblOWOHURep72120      = ds.Tables[1].Rows[3]["72<Hours>=120"].ToString();
                        objASC.lblOWOHURepgreater120 = ds.Tables[1].Rows[3][">120Hours"].ToString();
                    }


                    if (invoiceDetails != null && carryforward == 0)
                    {
                        foreach (DataRow dr in invoiceDetails.Tables[0].Rows)
                        {
                            if (dr["ActivityParameter_SNo"].ToString().Equals("0"))
                            {
                                objASC.lblQuanityfd   = dr["Quantity"].ToString();
                                objASC.lblfdUnitPrice = dr["UnitPrice"].ToString();
                                objASC.Amount         = Convert.ToString(dr["Amount"].ToString());
                            }
                        }
                    }
                    else
                    {
                        objASC.lblQuanityfd   = "0";
                        objASC.lblfdUnitPrice = "0.00";
                        objASC.Amount         = "0.00";
                    }
                    if (common == null)
                    {
                        common = new CommonClass();
                    }
                    common.InsertInvoice(objASC, Username, AscId, BranchId, RegionId, month, year, carryforward);
                }
            }
            catch (Exception ex)
            {
                Util.WriteToFile("function calculate " + ex.Message);
            }
        }