Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AppKey = Globals.Settings.AppServiceSecureKey;
            var controlTicketID = String.Empty;
            var idListString    = Request.QueryString["id"];
            var withUrMarker    = Request.QueryString["with_ur"];
            var ticketsCount    = 0;

            if (!String.IsNullOrEmpty(idListString))
            {
                List <string> idList    = idListString.Split('-').ToList();
                var           sqlString = String.Empty;
                foreach (var id in idList)
                {
                    sqlString       = sqlString + "T.`ID` = " + id + " OR ";
                    controlTicketID = id;
                }
                string fullSqlString;

                if (String.IsNullOrEmpty(withUrMarker))
                {
                    cbWithUr.Checked = false;
                    fullSqlString    = "SELECT T.`SecureID`, T.`ID`, T.`BoxesNumber`, T.`Weight`, T.`AgreedCost`, T.`AssessedCost`, T.`DriverID` " +
                                       "FROM `tickets` T " +
                                       "JOIN `usersprofiles` as U " +
                                       "ON T.`UserProfileID` = U.`ID` " +
                                       "WHERE (" + sqlString.Remove(sqlString.Length - 3) + ") AND `PrintNakl` = '1' AND U.`TypeID` = '1' AND (T.StatusID ='3' OR T.StatusID = '19')";
                }
                else
                {
                    cbWithUr.Checked = true;
                    fullSqlString    = "SELECT T.`SecureID`, T.`ID`, T.`BoxesNumber`, T.`Weight`, T.`AgreedCost`, T.`AssessedCost`, T.`DriverID` " +
                                       "FROM `tickets` T " +
                                       "JOIN `usersprofiles` U " +
                                       "ON T.`UserProfileID` = U.`ID` " +
                                       "WHERE (" + sqlString.Remove(sqlString.Length - 3) + ") AND (T.`PrintNaklInMap` = '0' OR U.`TypeID` = '1') AND (T.StatusID ='3' OR T.StatusID = '19')" +
                                       "ORDER BY T.`ID` DESC";
                }

                var     dm         = new DataManager();
                var     dataset    = dm.QueryWithReturnDataSet(fullSqlString);
                var     overBoxes  = 0;
                var     overWeight = 0;
                decimal overCost   = 0;
                var     driverID   = String.Empty;
                foreach (DataRow row in dataset.Tables[0].Rows)
                {
                    driverID    = row["DriverID"].ToString();
                    overBoxes  += Convert.ToInt32(row["BoxesNumber"]);
                    overWeight += String.IsNullOrEmpty(row["Weight"].ToString()) ? 0 : Convert.ToInt32(row["Weight"]);
                    overCost   += Convert.ToInt32(row["AgreedCost"]) != 0 ? Convert.ToDecimal(row["AgreedCost"]) : Convert.ToDecimal(row["AssessedCost"]);
                    ticketsCount++;
                }

                lblCar.Text    = DriversHelper.DriverIDToCarZP(driverID);
                lblDriver.Text = lblDriver2.Text = lblDriver3.Text = DriversHelper.DriverIDToNameZP(driverID);
                lblCost.Text   = lblCost2.Text = lblCost3.Text = lblCost4.Text = MoneyMethods.MoneySeparator(overCost.ToString());
                lblBoxes2.Text = lblBoxes3.Text = overBoxes.ToString();
                lblWeight.Text = lblWeight2.Text = overWeight.ToString();

                lblCostWord.Text = MoneyHelper.ToRussianString(overCost);

                lblWeightWord.Text = NumberToRussianString.NumberToString(
                    Convert.ToInt64(overWeight), NumberToRussianString.WordGender.Masculine);

                lblBoxesWord.Text = NumberToRussianString.NumberToString(
                    Convert.ToInt64(overBoxes), NumberToRussianString.WordGender.Masculine);

                Inpnaklnumber.Text =
                    dm.QueryWithReturnDataSet("SELECT `NaklNumber` FROM `printdata`").Tables[0].Rows[0][0]
                    .ToString();
                Inpseria.Text =
                    dm.QueryWithReturnDataSet("SELECT `NaklSeria` FROM `printdata`").Tables[0].Rows[0][0]
                    .ToString();
                Inpdate.Text =
                    dm.QueryWithReturnDataSet("SELECT `NaklDate` FROM `printdata`").Tables[0].Rows[0][0]
                    .ToString();
                Inpputevoi.Text =
                    dm.QueryWithReturnDataSet("SELECT `Putevoi` FROM `printdata`").Tables[0].Rows[0][0]
                    .ToString();

                var ticket = new Tickets {
                    ID = Convert.ToInt32(controlTicketID)
                };
                ticket.GetById();
            }

            #region Сообщение, если накладная пустая
            if (String.IsNullOrEmpty(idListString) || ticketsCount == 0)
            {
                Page.Visible = false;
                if (String.IsNullOrEmpty(idListString))
                {
                    Response.Write(Resources.PrintResources.PrintNaklEmptyText);
                }
                else
                {
                    Response.Write(Resources.PrintResources.PrintNaklEmptyText +
                                   String.Format("<br/><center><a href=\"{0}&with_ur=1\">печать с юр. лицами</a><center>", Request.RawUrl));
                }
            }
            #endregion
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AppKey = Globals.Settings.AppServiceSecureKey;
            var    controlTicketID = String.Empty;
            var    dm           = new DataManager();
            var    idListString = IdList = Request.QueryString["id"];
            var    withUrMarker = Request.QueryString["with_ur"];
            string whereUrSql;

            if (!String.IsNullOrEmpty(withUrMarker))
            {
                cbWithUr.Checked = true;
                whereUrSql       = " ";
            }
            else
            {
                whereUrSql       = " AND U.`TypeID` = '1' ";
                cbWithUr.Checked = false;
            }

            if (!String.IsNullOrEmpty(idListString))
            {
                List <string> idList    = idListString.Split('-').ToList();
                var           sqlString = String.Empty;
                foreach (var id in idList)
                {
                    sqlString       = sqlString + "T.ID = " + id + " OR ";
                    controlTicketID = id;
                }
                var fullSqlString = "SELECT * FROM `tickets` as T " +
                                    "JOIN `city` as C " +
                                    "ON T.CityID = C.ID " +
                                    "JOIN `usersprofiles` as U " +
                                    "ON T.`UserProfileID` = U.`ID` " +
                                    "WHERE ((" + sqlString.Remove(sqlString.Length - 3) + ") AND T.PrintNakl = '1' AND T.NotPrintInPril2 ='0'" + whereUrSql + ") "  //AND (T.StatusID ='3' OR T.StatusID = '19')
                ;

                var     dataset    = dm.QueryWithReturnDataSet(fullSqlString);
                var     iter       = 1;
                var     overBoxes  = 0;
                var     overWeight = 0;
                decimal overCost   = 0;
                DriverID = String.Empty;
                dataset.Tables[0].Columns.Add("PorID");
                dataset.Tables[0].Columns.Add("Pril2CostOrCost");

                foreach (DataRow row in dataset.Tables[0].Rows)
                {
                    row["PorID"] = iter.ToString();
                    iter++;
                    DriverID    = row["DriverID"].ToString();
                    overBoxes  += Convert.ToInt32(row["BoxesNumber"]);
                    overWeight += String.IsNullOrEmpty(row["Weight"].ToString()) ? 0 : Convert.ToInt32(row["Weight"]);

                    var zero = 0.00;
                    if (Convert.ToDouble(row["Pril2Cost"]) != zero)
                    {
                        overCost += Convert.ToDecimal(row["Pril2Cost"]);
                        row["Pril2CostOrCost"] = row["Pril2Cost"];
                    }
                    else
                    {
                        overCost += Convert.ToInt32(row["AgreedCost"]) != 0 ? Convert.ToDecimal(row["AgreedCost"]) : Convert.ToDecimal(row["AssessedCost"]);
                        row["Pril2CostOrCost"] = Convert.ToInt32(row["AgreedCost"]) != 0 ? row["AgreedCost"] : row["AssessedCost"];
                    }
                }

                lvAllPrint.DataSource = dataset;
                lvAllPrint.DataBind();

                try
                {
                    DriverName = dm.QueryWithReturnDataSet(String.Format("SELECT `FIO` FROM `drivers` WHERE `id` = {0}", DriverID)).Tables[0].Rows[0][0].ToString();
                }
                catch (Exception)
                {
                    DriverName = "Не назначен";
                }

                lblDriver.Text     = lblDriver2.Text = DriversHelper.DriverIDToNameZP(DriverID);
                lblOverNumber.Text = dataset.Tables[0].Rows.Count.ToString();
                lblOverCost.Text   = lblOverCost2.Text = lblOverCost3.Text = MoneyMethods.MoneySeparator(overCost.ToString());
                lblCostWord.Text   = MoneyHelper.ToRussianString(overCost);

                Inpnaklnumber.Text =
                    dm.QueryWithReturnDataSet("SELECT `NaklNumber` FROM `printdata`").Tables[0].Rows[0][0]
                    .ToString();
                Inpseria.Text =
                    dm.QueryWithReturnDataSet("SELECT `NaklSeria` FROM `printdata`").Tables[0].Rows[0][0]
                    .ToString();
                Inpdate.Text =
                    dm.QueryWithReturnDataSet("SELECT `NaklDate` FROM `printdata`").Tables[0].Rows[0][0]
                    .ToString();

                overGruzobozCost.Text =
                    MoneyMethods.MoneySeparator(
                        MoneyMethods.GruzobozCostLoweringPercentage(
                            dm.QueryWithReturnDataSet(
                                "SELECT SUM(`GruzobozCost`) " +
                                "FROM `tickets` T " +
                                "JOIN `usersprofiles` as U " +
                                "ON T.`UserProfileID` = U.`ID` " +
                                "WHERE ((" + sqlString.Remove(sqlString.Length - 3) + ") AND T.PrintNakl = '1' AND T.NotPrintInPril2 ='0'" + whereUrSql + ")" //AND (T.StatusID ='3' OR T.StatusID = '19')
                                ).Tables[0].Rows[0][0].ToString()
                            )
                        );

                var ticket = new Tickets {
                    ID = Convert.ToInt32(controlTicketID)
                };
                ticket.GetById();

                var notVisibleCount =
                    dm.QueryWithReturnDataSet(
                        "SELECT COUNT(*) " +
                        "FROM `tickets` as T " +
                        "JOIN `usersprofiles` as U " +
                        "ON T.`UserProfileID` = U.`ID` " +
                        "WHERE ((" + sqlString.Remove(sqlString.Length - 3) + ") AND T.PrintNakl = '1' AND T.NotPrintInPril2 ='1'" + whereUrSql + ")").Tables[0].Rows[0][0].ToString(); //AND (T.StatusID ='3' OR T.StatusID = '19')
                btnReload.Enabled = notVisibleCount == "0";

                //рассчет недостающих коробок и веса СТАРТ

                var notVisibleTicketsTable = dm.QueryWithReturnDataSet(
                    "SELECT T.Weight, T.AgreedCost, T.AssessedCost, T.BoxesNumber " +
                    "FROM `tickets` as T " +
                    "JOIN `usersprofiles` as U " +
                    "ON T.`UserProfileID` = U.`ID` " +
                    "WHERE ((" + sqlString.Remove(sqlString.Length - 3) + ") AND T.PrintNakl = '1' AND NotPrintInPril2 ='1'" + whereUrSql + ")").Tables[0]; //AND (T.StatusID ='3' OR T.StatusID = '19')

                foreach (DataRow row in notVisibleTicketsTable.Rows)
                {
                    overBoxes  += Convert.ToInt32(row["BoxesNumber"]);
                    overWeight += String.IsNullOrEmpty(row["Weight"].ToString()) ? 0 : Convert.ToInt32(row["Weight"]);
                }

                lblOverBoxes.Text = overBoxes.ToString();
                lblBoxesWord.Text = NumberToRussianString.NumberToString(
                    Convert.ToInt64(overBoxes), NumberToRussianString.WordGender.Masculine);
                lblOverWeight.Text = overWeight.ToString();
                lblWeightWord.Text = NumberToRussianString.NumberToString(
                    Convert.ToInt64(overWeight), NumberToRussianString.WordGender.Masculine);
                //рассчет недостающих коробок и веса КОНЕЦ

                if (OneCMethods.IfFileExist())
                {
                    btnCSVStart.Enabled = false;
                }
                else
                {
                    btnCSVAdd.Enabled = false;
                    btnCSVEnd.Enabled = false;
                }
            }

            if (String.IsNullOrEmpty(idListString) || lvAllPrint.Items.Count == 0)
            {
                Page.Visible = false;
                if (String.IsNullOrEmpty(idListString))
                {
                    Response.Write(Resources.PrintResources.PrintNaklPrilEmptyText);
                }
                else
                {
                    Response.Write(Resources.PrintResources.PrintNaklPrilEmptyText +
                                   String.Format("<br/><center><a href=\"{0}&with_ur=1\">печать с юр. лицами</a><center>", Request.RawUrl));
                }
                Page.Visible = false;
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AppKey = Globals.Settings.AppServiceSecureKey;
            var controlTicketID = String.Empty;
            var idListString    = TicketIdList = Request.QueryString["id"];
            var withUrMarker    = Request.QueryString["with_ur"];

            if (!String.IsNullOrEmpty(idListString))
            {
                List <string> idList    = idListString.Split('-').ToList();
                var           sqlString = String.Empty;
                foreach (var id in idList)
                {
                    sqlString       = sqlString + "T.`ID` = " + id + " OR ";
                    controlTicketID = id;
                }
                string fullSqlString;
                if (String.IsNullOrEmpty(withUrMarker))
                {
                    cbWithUr.Checked = false;
                    fullSqlString    =
                        "SELECT T.`SecureID`, T.`ID`, T.`BoxesNumber`, T.`Weight`, T.`AgreedCost`, T.`AssessedCost`, T.`DriverID` " +
                        "FROM `tickets` T " +
                        "JOIN `usersprofiles` U " +
                        "ON T.`UserProfileID` = U.`ID` " +
                        "WHERE (" + sqlString.Remove(sqlString.Length - 3) +
                        ") AND U.`TypeID` = '1' AND (T.StatusID ='3' OR T.StatusID = '19')" +
                        "ORDER BY T.`ID` DESC";
                }
                else
                {
                    cbWithUr.Checked = true;
                    fullSqlString    =
                        "SELECT T.`SecureID`, T.`ID`, T.`BoxesNumber`, T.`Weight`, T.`AgreedCost`, T.`AssessedCost`, T.`DriverID` " +
                        "FROM `tickets` T " +
                        "JOIN `usersprofiles` U " +
                        "ON T.`UserProfileID` = U.`ID` " +
                        "WHERE (" + sqlString.Remove(sqlString.Length - 3) + ") AND (T.`PrintNaklInMap` = '0' OR U.`TypeID` = '1') AND (T.StatusID ='3' OR T.StatusID = '19')" +
                        "ORDER BY T.`ID` DESC";
                }

                var     dm         = new DataManager();
                var     dataset    = dm.QueryWithReturnDataSet(fullSqlString);
                var     iter       = 1;
                var     overBoxes  = 0;
                var     overWeight = 0;
                decimal overCost   = 0;
                DriverID = String.Empty;
                dataset.Tables[0].Columns.Add("PorID");

                foreach (DataRow row in dataset.Tables[0].Rows)
                {
                    row["PorID"] = iter.ToString();
                    iter++;
                    DriverID    = row["DriverID"].ToString();
                    overBoxes  += Convert.ToInt32(row["BoxesNumber"]);
                    overWeight += String.IsNullOrEmpty(row["Weight"].ToString()) ? 0 : Convert.ToInt32(row["Weight"]);
                    overCost   += Convert.ToInt32(row["AgreedCost"]) != 0 ? Convert.ToDecimal(row["AgreedCost"]) : Convert.ToDecimal(row["AssessedCost"]);
                }
                lvAllPrint.DataSource = dataset;
                lvAllPrint.DataBind();

                try
                {
                    DriverName = dm.QueryWithReturnDataSet(String.Format("SELECT CONCAT(`FirstName`, ' ',  `LastName`, ' ', `ThirdName`) FROM `drivers` WHERE `id` = {0}", DriverID)).Tables[0].Rows[0][0].ToString();
                }
                catch (Exception)
                {
                    DriverName = "Не назначен";
                }

                lblDriver.Text     = lblDriver2.Text = DriversHelper.DriverIDToNameZP(DriverID);
                lblOverNumber.Text = dataset.Tables[0].Rows.Count.ToString();
                lblOverCost.Text   = lblOverCost2.Text = MoneyMethods.MoneySeparator(overCost.ToString());

                lblCostWord.Text = MoneyHelper.ToRussianString(overCost);

                lblOverBoxes.Text = overBoxes.ToString();
                lblBoxesWord.Text = NumberToRussianString.NumberToString(
                    Convert.ToInt64(overBoxes), NumberToRussianString.WordGender.Masculine);
                lblOverWeight.Text = overWeight.ToString();
                lblWeightWord.Text = NumberToRussianString.NumberToString(
                    Convert.ToInt64(overWeight), NumberToRussianString.WordGender.Masculine);

                Inpnaklnumber.Text =
                    dm.QueryWithReturnDataSet("SELECT `NaklNumber` FROM `printdata`").Tables[0].Rows[0][0]
                    .ToString();
                Inpseria.Text =
                    dm.QueryWithReturnDataSet("SELECT `NaklSeria` FROM `printdata`").Tables[0].Rows[0][0]
                    .ToString();
                Inpdate.Text =
                    dm.QueryWithReturnDataSet("SELECT `NaklDate` FROM `printdata`").Tables[0].Rows[0][0]
                    .ToString();

                var ticket = new Tickets {
                    ID = Convert.ToInt32(controlTicketID)
                };
                ticket.GetById();
            }

            if (String.IsNullOrEmpty(idListString) || lvAllPrint.Items.Count == 0)
            {
                Page.Visible = false;
                if (String.IsNullOrEmpty(idListString))
                {
                    Response.Write(Resources.PrintResources.PrintNaklPrilEmptyText);
                }
                else
                {
                    Response.Write(Resources.PrintResources.PrintNaklPrilEmptyText +
                                   String.Format("<br/><center><a href=\"{0}&with_ur=1\">печать с юр. лицами</a><center>", Request.RawUrl));
                }
                Page.Visible = false;
            }
        }