Пример #1
0
 public void btnCSVEnd_Click(Object sender, EventArgs e)
 {
     OneCMethods.EndSession();
     Page.Response.Redirect(Request.RawUrl);
 }
Пример #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;
            }
        }
Пример #3
0
 public void btnCSVAdd_Click(Object sender, EventArgs e)
 {
     OneCMethods.GenerateCsv(Request.QueryString["id"], Inpnaklnumber.Text, Inpseria.Text, Inpdate.Text);
 }