Exemplo n.º 1
0
        string CheckAccount()
        {
            if (string.IsNullOrEmpty(User.Identity.Name))
            {
                Response.Redirect("~/Account/Login.aspx");
            }

            List <string> roles = new List <string>()
            {
                "ODS", "Cadry"
            };

            App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return("ODS");
            }
            roles = new List <string>()
            {
                "Administrator"
            };
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return("Administrator");
            }
            roles = new List <string>()
            {
                "Manager"
            };
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return("Manager");
            }
            roles = new List <string>()
            {
                "Cadry"
            };
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return("Worker");
            }
            Response.Redirect("~/About.aspx");
            return("");
        }
Exemplo n.º 2
0
        void CheckAccount()
        {
            if (string.IsNullOrEmpty(User.Identity.Name))
            {
                Response.Redirect("~/Account/Login.aspx?ReturnUrl=~/Enviroment.aspx");
            }

            List <string> roles = new List <string>()
            {
                "Administrator", "Manager", "Electronick", "Cadry"
            };

            App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return;
            }
            Response.Redirect("~/About.aspx");
        }
Exemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(Request["zId"]))
     {
         // if (!string.IsNullOrEmpty(Request["zId"]) && !IsPostBack)
         Response.Redirect("~/About.aspx");
     }
     _wz = Int32.Parse(Request["zId"]);
     if (!IsPostBack)
     {
         App_Code.Base db   = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
         DataTable     data = db.GetEvent(_wz);
         if (data.Rows.Count < 1)
         {
             Response.Redirect("~/About.aspx");
         }
         Id.Text        = _wz.ToString();
         EventId.Text   = data.Rows[0]["EventId"].ToString(); ZaprosMng.Checked = Boolean.Parse(data.Rows[0]["ZaprosMng"].ToString());
         DataId.Text    = data.Rows[0]["DataId"].ToString();   ZaprosKP.Checked = Boolean.Parse(data.Rows[0]["ZaprosKP"].ToString());
         KP.Checked     = Boolean.Parse(data.Rows[0]["KP"].ToString());
         Comment.Text   = data.Rows[0]["Comment"].ToString(); ZapBill.Checked = Boolean.Parse(data.Rows[0]["ZapBill"].ToString());
         Prim.Text      = data.Rows[0]["Prim"].ToString();       Bill.Checked = Boolean.Parse(data.Rows[0]["Bill"].ToString());
         Idz.Text       = data.Rows[0]["ZayavId"].ToString();     Payment.Checked = Boolean.Parse(data.Rows[0]["Payment"].ToString());
         Idwz.Text      = data.Rows[0]["WZayavId"].ToString();   Dostavka.Checked = Boolean.Parse(data.Rows[0]["Dostavka"].ToString());
         LiftId.Text    = data.Rows[0]["LiftId"].ToString();   Prihod.Checked = Boolean.Parse(data.Rows[0]["Prihod"].ToString());
         Sourse.Text    = data.Rows[0]["Sourse"].ToString();   Peremeshenie.Checked = Boolean.Parse(data.Rows[0]["Peremeshenie"].ToString());
         Family.Text    = data.Rows[0]["Family"].ToString();   AktVR.Checked = Boolean.Parse(data.Rows[0]["AktVR"].ToString());
         TypeId.Text    = data.Rows[0]["TypeId"].ToString();   Spisanie.Checked = Boolean.Parse(data.Rows[0]["Spisanie"].ToString());
         ToApp.Text     = data.Rows[0]["ToApp"].ToString();     Cansel.Checked = Boolean.Parse(data.Rows[0]["Cansel"].ToString());
         DateToApp.Text = data.Rows[0]["DateToApp"].ToString();
         Who.Text       = data.Rows[0]["Who"].ToString();
         DateWho.Text   = data.Rows[0]["DateWho"].ToString();
         TimeSpan pr = DateTime.Now - ((DateTime)data.Rows[0]["DataId"]);
         if (!(data.Rows[0]["DateWho"] is DBNull))
         {
             pr = ((DateTime)data.Rows[0]["DateWho"]) - ((DateTime)data.Rows[0]["DataId"]);
         }
         string prostoy = ((int)pr.TotalDays).ToString() + " " + pr.Hours.ToString() + ":" +
                          pr.Minutes.ToString();
         Timing.Text = prostoy;
     }
 }
Exemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     CheckAccount();
     App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
     _workers = db.GetWorkers();
     if (!IsPostBack)
     {
         Worker.DataSource = _workers;
         Worker.DataBind();
         Worker.SelectedIndex = 0;
         List <string> ls = db.GetIdU();
         IdU.DataSource = ls;
         IdU.DataBind();
         if (ls.Count > 0)
         {
             IdU.SelectedIndex = 0;
         }
         IdU_SelectedIndexChanged(sender, e);
     }
 }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckAccount();

            if (!string.IsNullOrEmpty(Request["U"]))
            {
                idU = HttpUtility.HtmlDecode(Request["U"]);
            }
            if (!string.IsNullOrEmpty(Request["M"]))
            {
                idM = HttpUtility.HtmlDecode(Request["M"]);
            }

            if (!IsPostBack)
            {
                App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                List <App_Code.Base.StoppedLift> list = db.GetStoppedLifts(idU, idM);
                Stop.DataSource = list;
                Stop.DataBind();
            }
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request["y"]) && !string.IsNullOrEmpty(Request["m"]))
            {
                _year  = Int32.Parse(Request["y"]);
                _month = Int32.Parse(Request["m"]);
            }
            else
            {
                _year  = DateTime.Now.Year;
                _month = DateTime.Now.Month;
            }
            _role = CheckAccount();

            if (!IsPostBack)
            {
                if (_role == "ODS")
                {
                    Qst.Visible = false;
                    Out.Visible = true;
                }
                else
                {
                    App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                    List <string> ls = db.GetIdU();
                    IdU.DataSource = ls;
                    IdU.DataBind();
                    if (ls.Count > 0)
                    {
                        IdU.SelectedIndex = 0;
                    }
                    IdU_SelectedIndexChanged(sender, e);
                    PeriodBeg.SelectedDate = DateTime.Now.AddMonths(-1);
                    PeriodEnd.SelectedDate = DateTime.Now;
                    Type.DataSource        = LiftsReport._types;
                    Type.DataBind();
                    Type.SelectedIndex = 0;
                }
            }
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Request["day"]))
            {
                _date = DateTime.Now.Date;
            }
            else
            {
                _date = DateTime.Parse(HttpUtility.HtmlDecode(Request["day"]));
            }
            DateTime d2 = _date.AddDays(1);

            _user = Page.User.Identity.Name;
            if (!string.IsNullOrEmpty(Request["user"]))
            {
                _user = HttpUtility.HtmlDecode(Request["user"]);
            }

            App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            _userInfo = db.GetUserInfo(_user);
            _data     = db.GetPlan(_user, _date, d2);
        }
Exemplo n.º 8
0
 protected override void OnPreRender(EventArgs e)
 {
     base.OnPreRender(e);
     if (_role == "ODS" || _role == "Cadry")
     {
         App_Code.Base db    = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
         List <string> lifts = db.GetODSLiftList(User.Identity.Name);
         LiftsRep.Set(lifts, new DateTime(_year, _month, 1),
                      new DateTime(_year, _month, DateTime.DaysInMonth(_year, _month)), "Всё", _role); //"Всё"
         if (_month > 1)
         {
             PrevMonth.Text        = KOS.App_Code.Base.months[_month - 2] + " " + _year.ToString();
             PrevMonth.NavigateUrl = "~/Lifts.aspx?y=" + _year.ToString() + "&m=" + (_month - 1).ToString();
         }
         else
         {
             PrevMonth.Text        = KOS.App_Code.Base.months[11] + " " + (_year - 1).ToString();
             PrevMonth.NavigateUrl = "~/Lifts.aspx?y=" + (_year - 1).ToString() + "&m=12";
         }
         if (_month < 12)
         {
             NextMonth.Text        = KOS.App_Code.Base.months[_month] + " " + _year.ToString();
             NextMonth.NavigateUrl = "~/Lifts.aspx?y=" + _year.ToString() + "&m=" + (_month + 1).ToString();
         }
         else
         {
             NextMonth.Text        = KOS.App_Code.Base.months[0] + " " + (_year + 1).ToString();
             NextMonth.NavigateUrl = "~/Lifts.aspx?y=" + (_year + 1).ToString() + "&m=1";
         }
         phGo.Visible = true;
     }
     else
     {
         List <string> lifts = GetSelectedTitles(IdL);
         LiftsRep.Set(lifts, PeriodBeg.SelectedDate, PeriodEnd.SelectedDate.AddDays(1), Type.SelectedValue, _role);
     }
 }
Exemplo n.º 9
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (User.Identity.Name == "Миракс_Парк")
            {
                PinAdmin.Visible = false;
                PinDisp.Visible  = false;
                use = "ОДС13";
            }
            else if (User.Identity.Name == "Корона_1")
            {
                PinAdmin1.Visible = false;
                PinDisp1.Visible  = false;
                use = "ОДС14";
            }
            else
            {
                return;
            }
            App_Code.Base db   = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            DataTable     data = db.GetPin(Pn.Text, use);

            try
            {
                Text.Text = "Здравствуйте, " + data.Rows[0]["surname"].ToString() + " " + data.Rows[0]["name"].ToString() + data.Rows[0]["midlename"].ToString() + "!";
                if (User.Identity.Name == "Корона_1")
                {
                    PinAdmin.Visible = true; PinDisp.Visible = true;
                }
                if (User.Identity.Name == "Миракс_Парк")
                {
                    PinAdmin1.Visible = true; PinDisp1.Visible = true;
                }
                Vpin.Visible = false;
            }
            catch { Msg.Text = "Пароль не верный, введите правильный пароль или обратитесь к аминистратору КОС!"; return; }
        }
Exemplo n.º 10
0
        string CheckAccount()
        {
            if (string.IsNullOrEmpty(User.Identity.Name))
            {
                Response.Redirect("~/Account/Login.aspx?ReturnUrl=~/Zayavka.aspx");
            }

            List <string> roles = new List <string>()
            {
                "ODS"
            };

            App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                XmlDocument doc = new XmlDocument();
                if (!File.Exists(ipConfig))
                {
                    SaveFirst(doc);
                }
                XmlTextReader reader = new XmlTextReader(ipConfig);
                doc.Load(reader);
                XmlNode ipx = doc["zayavka"][User.Identity.Name];
                reader.Close();
                if (ipx != null && ipx.HasChildNodes)
                {
                    for (int i = 0; i < ipx.ChildNodes.Count; i++)
                    {
                        string ip = ipx.ChildNodes[i].InnerText;
                        if (ip == Request.UserHostAddress || ip == "*")
                        {
                            return("ODS");
                        }
                    }
                    Response.Redirect("~/About.aspx");
                }
                else
                {
                    SaveNext(doc);
                }
                return("ODS");
            }
            roles = new List <string>()
            {
                "Administrator", "Cadry"
            };
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return("Administrator");
            }
            roles = new List <string>()
            {
                "Manager"
            };
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return("Manager");
            }
            roles = new List <string>()
            {
                "Worker"
            };
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return("Worker");
            }
            roles = new List <string>()
            {
                "Cadry "
            };
            if (db.CheckAccount(User.Identity.Name, roles))
            {
                return("Cadry");
            }

            Response.Redirect("~/About.aspx");
            return(null);
        }
Exemplo n.º 11
0
        string BuildWhere()
        {
            string s = BuildWorkerWhere();

            if (s == null)
            {
                return(s);
            }
            if (_role == "Worker")
            {
                if (string.IsNullOrEmpty(s))
                {
                    s = "where ";
                }
                else
                {
                    s += "and ";
                }
                App_Code.Base          db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                App_Code.Base.UserInfo ui = db.GetUserInfo(Page.User.Identity.Name);
                WorkerData awd = workerData.Find(delegate(WorkerData wd)
                {
                    return(wd.Title == ui.Family + " " + ui.IO);
                });
                if (awd != null)
                {
                    s += "p.UserId='" + awd.Id + "' ";
                }
                else
                {
                    return(null);
                }
            }
            else if (!IsAllSelected(Worker) || workerData.Count == 1)
            {
                List <string> ls = GetSelectedTitles(Worker);
                string        ss = string.Empty;
                foreach (string i in ls)
                {
                    WorkerData awd = workerData.Find(delegate(WorkerData wd)
                    {
                        return(wd.Title == i);
                    });
                    if (awd != null)
                    {
                        ss += (string.IsNullOrEmpty(ss) ? "" : ",") + "'" + awd.Id + "'";
                    }
                }
                if (!string.IsNullOrEmpty(ss))
                {
                    if (string.IsNullOrEmpty(s))
                    {
                        s = "where ";
                    }
                    else
                    {
                        s += "and ";
                    }
                    s += "p.UserId in (" + ss + ") ";
                }
                else
                {
                    return(null);
                }
            }

            if (!IsAllSelected(Done))
            {
                List <string> ls   = GetSelectedTitles(Done);
                int           done = 0;
                if (ls.Count > 0)
                {
                    if (ls[0] == "выполнено")
                    {
                        done = 1;
                    }
                }
                else
                {
                    return(null);
                }
                if (string.IsNullOrEmpty(s))
                {
                    s = "where ";
                }
                else
                {
                    s += "and ";
                }
                s += "p.[Done]=" + done.ToString() + " ";
            }

            if (s != null)
            {
                if (string.IsNullOrEmpty(s))
                {
                    s = "where ";
                }
                else
                {
                    s += "and ";
                }
                s += "p.[Date] between @DateStart and @DateEnd ";
            }

            return(s);
        }
Exemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Request["zId"]))
            {
                // if (!string.IsNullOrEmpty(Request["zId"]) && !IsPostBack)
                Response.Redirect("~/About.aspx");
            }
            _wz = Int32.Parse(Request["zId"]);
            //    if (User.Identity.Name != "ODS14") { Treg.Visible = false; Tzak.Visible = false; }
            if (!IsPostBack)
            {
                App_Code.Base db   = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                DataTable     data = db.GetEvent(_wz);
                if (data.Rows.Count < 1)
                {
                    Response.Redirect("~/About.aspx");
                }
                Id.Text     = _wz.ToString();
                Sourse.Text = data.Rows[0]["Sourse"].ToString();
                //   Text1.Text = data.Rows[0]["Sourse"].ToString();
                IO.Text        = data.Rows[0]["IO"].ToString();
                DataId.Text    = data.Rows[0]["DataId"].ToString();
                dateReg        = ((DateTime)data.Rows[0]["DataId"]);
                ZayavId.Text   = data.Rows[0]["ZayavId"].ToString();
                RegistrId.Text = data.Rows[0]["RegistrId"].ToString();
                LiftId.Text    = data.Rows[0]["LiftId"].ToString();
                //    TextBox4.Text = data.Rows[0]["LiftId"].ToString();
                TypeId.Text  = data.Rows[0]["TypeId"].ToString();
                EventId.Text = data.Rows[0]["EventId"].ToString();
                //    Text.Text = data.Rows[0]["EventId"].ToString();
                ToApp.Text = data.Rows[0]["ToApp"].ToString();
                //    Text2.Text = data.Rows[0]["ToApp"].ToString();
                DateToApp.Text = data.Rows[0]["DateToApp"].ToString();

                Who.Text     = data.Rows[0]["Who"].ToString();
                Comment.Text = data.Rows[0]["Comment"].ToString();
                //     Text5.Text = data.Rows[0]["Prim"].ToString();
                Prim.Text    = data.Rows[0]["Prim"].ToString();
                DateWho.Text = data.Rows[0]["DateWho"].ToString();
                // clos = ((DateTime)data.Rows[0]["DateWho"]);
                Date.Text = DateTime.Now.ToLongDateString();
                string   d = string.Empty;
                string   d2 = string.Empty, t2 = string.Empty;
                TimeSpan pr = DateTime.Now - ((DateTime)data.Rows[0]["DataId"]);
                if (!(data.Rows[0]["DateWho"] is DBNull))
                {
                    d2 = ((DateTime)data.Rows[0]["DateWho"]).Date.ToString();
                    t2 = ((DateTime)data.Rows[0]["DateWho"]).TimeOfDay.ToString();
                    pr = ((DateTime)data.Rows[0]["DateWho"]) - ((DateTime)data.Rows[0]["DataId"]);
                }
                if (!(data.Rows[0]["DateToApp"] is DBNull))
                {
                    d = ((DateTime)data.Rows[0]["DateToApp"]).ToString();
                }
                string prostoy = ((int)pr.TotalDays).ToString() + " дн. " + pr.Hours.ToString() + " час. " +
                                 pr.Minutes.ToString() + " мин.";
                Timing.Text  = prostoy;
                DocName.Text = "документ";
                //Год/месяц/день

                /*    List<string> xx = new List<string>() {  "Акт неисправности", "Акт внеплановых работ", "Платежное поручение", "Счет" };
                 *  if (!IsPostBack)
                 *  {
                 *      DocName.DataSource = xx;
                 *      DocName.DataBind();
                 *      DocName.SelectedIndex = 0;
                 *  } */
                using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("select count(d.Id) from Documents d" +
                                                    " where d.NumEvent=@id and d.Usr=@usr", conn);
                    cmd.Parameters.AddWithValue("id", _wz);
                    cmd.Parameters.AddWithValue("usr", User.Identity.Name);
                    UsrDoc.Text = cmd.ExecuteScalar().ToString();
                }
                List <Data> datadoc = GetData();
                Out.DataSource = datadoc;
                Out.DataBind();

                List <Data> datdoc = GetData1();
                Out1.DataSource = datdoc;
                Out1.DataBind();
                //  DocPodp.Visible = true;
            }
        }
Exemplo n.º 13
0
 void FillLabels()
 {
     lPrinyalDate.Text = " с " + Calendar.SelectedDate.ToLongDateString() + " по " +
                         CalendarEnd.SelectedDate.ToLongDateString();
     if (IsAllSelected(IdU))
     {
         lU.Text = " любой";
     }
     else
     {
         List <string> ls = GetSelectedTitles(IdU);
         for (int i = 0; i < ls.Count; i++)
         {
             if (i == 0)
             {
                 lU.Text = ls[i];
             }
             else
             {
                 lU.Text += ", " + ls[i];
             }
         }
     }
     if (IsAllSelected(IdM))
     {
         lM.Text = " любой";
     }
     else
     {
         List <string> ls = GetSelectedTitles(IdM);
         for (int i = 0; i < ls.Count; i++)
         {
             if (i == 0)
             {
                 lM.Text = ls[i];
             }
             else
             {
                 lM.Text += ", " + ls[i];
             }
         }
     }
     if (IsAllSelected(IdL))
     {
         lL.Text = " любой";
     }
     else
     {
         List <string> ls = GetSelectedTitles(IdL);
         for (int i = 0; i < ls.Count; i++)
         {
             if (i == 0)
             {
                 lL.Text = ls[i];
             }
             else
             {
                 lL.Text += ", " + ls[i];
             }
         }
     }
     if (IsAllSelected(Address))
     {
         if (GetSelectedTitles(IdU).Count == 1 && GetSelectedTitles(IdM).Count == 1)
         {
             KOS.App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
             List <string>     ls = db.GetAddress(GetSelectedTitles(IdU)[0], GetSelectedTitles(IdM)[0]);
             lAddress.Text = string.Empty;
             foreach (string s in ls)
             {
                 if (!string.IsNullOrEmpty(lAddress.Text))
                 {
                     lAddress.Text += ", ";
                 }
                 lAddress.Text += s;
             }
         }
         else
         {
             lAddress.Text = " любой";
         }
     }
     else
     {
         List <string> ls = GetSelectedTitles(Address);
         for (int i = 0; i < ls.Count; i++)
         {
             if (i == 0)
             {
                 lAddress.Text = ls[i];
             }
             else
             {
                 lAddress.Text += ", " + ls[i];
             }
         }
     }
     if (IsAllSelected(WorkType))
     {
         lWorkType.Text = " любой";
     }
     else
     {
         List <string> ls = GetSelectedTitles(WorkType);
         for (int i = 0; i < ls.Count; i++)
         {
             if (i == 0)
             {
                 lWorkType.Text = ls[i];
             }
             else
             {
                 lWorkType.Text += ", " + ls[i];
             }
         }
     }
     if (_role == "Worker")
     {
         App_Code.Base          db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
         App_Code.Base.UserInfo ui = db.GetUserInfo(Page.User.Identity.Name);
         lWorker.Text = ui.Family + " " + ui.IO;
     }
     else if (IsAllSelected(Worker))
     {
         lWorker.Text = " любой";
     }
     else
     {
         List <string> ls = GetSelectedTitles(Worker);
         for (int i = 0; i < ls.Count; i++)
         {
             if (i == 0)
             {
                 lWorker.Text = ls[i];
             }
             else
             {
                 lWorker.Text += ", " + ls[i];
             }
         }
     }
     if (IsAllSelected(Done))
     {
         lDone.Text = " любое состояние";
     }
     else
     {
         List <string> ls = GetSelectedTitles(Done);
         if (ls.Count > 0)
         {
             lDone.Text = ls[0];
         }
     }
 }
Exemplo n.º 14
0
 void FillLabels()
 {
     lDate.Text = " с " + Start.SelectedDate.ToLongDateString() + " по " +
                  End.SelectedDate.ToLongDateString();
     if (IsAllSelected(IdU))
     {
         lU.Text = " любой";
     }
     else
     {
         lU.Text = GetSelected(IdU);
     }
     if (IsAllSelected(IdM))
     {
         lM.Text = " любой";
     }
     else
     {
         lM.Text = GetSelected(IdM);
     }
     if (IsAllSelected(IdL))
     {
         lL.Text = " любой";
     }
     else
     {
         lL.Text = GetSelected(IdL);
     }
     if (IsAllSelected(Address))
     {
         if (GetSelectedTitles(IdU).Count == 1 && GetSelectedTitles(IdM).Count == 1)
         {
             KOS.App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
             List <string>     ls = db.GetAddress(GetSelectedTitles(IdU)[0], GetSelectedTitles(IdM)[0]);
             lAddress.Text = string.Empty;
             foreach (string s in ls)
             {
                 if (!string.IsNullOrEmpty(lAddress.Text))
                 {
                     lAddress.Text += ", ";
                 }
                 lAddress.Text += s;
             }
         }
         else
         {
             lAddress.Text = " любой";
         }
     }
     else
     {
         lAddress.Text = GetSelected(Address);
     }
     if (IsAllSelected(Category))
     {
         lCategory.Text = " любая";
     }
     else
     {
         lCategory.Text = GetSelected(Category);
     }
     if (IsAllSelected(Done))
     {
         lDone.Text = " любые";
     }
     else
     {
         lDone.Text = GetSelected(Done);
     }
 }
Exemplo n.º 15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckAccount();

            if (!string.IsNullOrEmpty(Request["id"]))
            {
                _id = Int32.Parse(Request["id"]);
                phAddRecord.Visible  = false;
                phEditRecord.Visible = true;
            }
            App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            _data = db.GetUsers();
            List <string> roles = new List <string>()
            {
                "Administrator", "Manager", "Cadry"
            };

            if (!db.CheckAccount(User.Identity.Name, roles))
            {
                Select.SelectCommand = "select j.*, uf.Family+' '+uf.IO as FromFIO, ut.Family+' '+ut.IO as ToFIO, '~/Journal.aspx?id='+CAST(j.Id as nvarchar) as Url " +
                                       "from [Journal] j left join UserInfo uf on uf.UserId=j.[From] left join UserInfo ut on ut.UserId=j.[To] " +
                                       "join Users u1 on u1.UserId=j.[From] or j.[From] is null " +
                                       "join Users u2 on u2.UserId=j.[To] or j.[To] is null " +
                                       "where (j.[From] is not null and u1.UserName=N'" + User.Identity.Name + "') " +
                                       "or (j.[To] is not null and u2.UserName=N'" + User.Identity.Name + "') " +
                                       "order by j.[Begin] desc";
            }
            if (!IsPostBack)
            {
                AddTo.DataSource = _data;
                AddTo.DataBind();
                AddTo.SelectedIndex = 0;
                using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    conn.Open();

                    /*
                     * SqlCommand cmd = new SqlCommand("select * from [Journal] order by [Begin] desc", conn);
                     * SqlDataReader dr = cmd.ExecuteReader();
                     * List<Data> data = new List<Data>();
                     * while (dr.Read())
                     * {
                     *  data.Add(new Data()
                     *  {
                     *      Id = dr["Id"].ToString(),
                     *      Url = "~/Journal.aspx?id=" + dr["Id"].ToString(),
                     *      Role = dr["Role"].ToString(),
                     *      Page = dr["Page"].ToString(),
                     *      Description = dr["Description"].ToString(),
                     *      Begin = ((DateTime)dr["Begin"]).Date.ToShortDateString(),
                     *      End = dr["End"] is DBNull ? "" : ((DateTime)dr["End"]).Date.ToShortDateString(),
                     *      Prim = dr["Prim"] is DBNull ? "" : dr["Prim"].ToString()
                     *  });
                     * }
                     * dr.Close();
                     * Table.DataSource = data;
                     * Table.DataBind();
                     */
                    if (_id > 0)
                    {
                        SqlCommand cmd = new SqlCommand("select j.*, uif.Family as FromF, uif.IO as FromIO, uit.Family as ToF, uit.IO as ToIO from [Journal] j " +
                                                        "left join UserInfo uit on uit.UserId=j.[To] " +
                                                        "left join UserInfo uif on uif.UserId=j.[From] where j.Id=@id", conn);
                        cmd.Parameters.AddWithValue("id", _id);
                        SqlDataAdapter da = new SqlDataAdapter(cmd);
                        DataTable      dt = new DataTable();
                        da.Fill(dt);
                        EditRole.Text        = dt.Rows[0]["Role"].ToString();
                        EditPage.Text        = dt.Rows[0]["Page"].ToString();
                        EditDescription.Text = dt.Rows[0]["Description"].ToString();
                        if (!(dt.Rows[0]["Prim"] is DBNull))
                        {
                            EditPrim.Text = dt.Rows[0]["Prim"].ToString();
                        }
                        if (!(dt.Rows[0]["FromF"] is DBNull))
                        {
                            EditFrom.Text = dt.Rows[0]["FromF"].ToString() + " " + dt.Rows[0]["FromIO"].ToString();
                        }
                        if (!(dt.Rows[0]["ToF"] is DBNull))
                        {
                            EditTo.Text = dt.Rows[0]["ToF"].ToString() + " " + dt.Rows[0]["ToIO"].ToString();
                        }
                    }
                }
            }
        }
Exemplo n.º 16
0
        string BuildWhere()
        {
            string s = string.Empty;

            s = " where wz.[Date] between @start and @end";
            if (_role == "Worker")
            {
                if (SelectDone.Checked && SelectNotDone.Checked)
                {
                    lType.Text = "все";
                }
                else if (SelectDone.Checked)
                {
                    s         += " and wz.[Done]=1";
                    lType.Text = "прорабу";
                }
                else if (SelectNotDone.Checked)
                {
                    s         += " and wz.[Done]=0";
                    lType.Text = "механик";
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                if (!IsAllSelected(Type))
                {
                    s += " and wz.[Done]=";
                    List <string> sel = GetSelectedTitles(Type);
                    if (sel.Count < 1)
                    {
                        return(null);
                    }
                    if (sel[0] == _type[0].Title)
                    {
                        s += "1";
                    }
                    else
                    {
                        s += "0";
                    }
                    lType.Text = sel[0];
                }
                else
                {
                    lType.Text = "все";
                }
            }

            if (_role == "Worker")
            {
                App_Code.Base          db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                App_Code.Base.UserInfo ui = db.GetUserInfo(Page.User.Identity.Name);
                lFrom.Text         = ui.Family + " " + ui.IO;
                Base.PersonData pd = workerData.Find(delegate(Base.PersonData p)
                {
                    return(p.Title == lFrom.Text);
                });
                if (pd == null)
                {
                    return(null);
                }
                s += " and wz.UserId='" + pd.Id + "'";
            }
            else if (!IsAllSelected(From))
            {
                string        from = string.Empty;
                List <string> sel  = GetSelectedTitles(From);
                if (sel.Count < 1)
                {
                    return(null);
                }
                foreach (string f in sel)
                {
                    Base.PersonData pd = workerData.Find(delegate(Base.PersonData p)
                    {
                        return(p.Title == f);
                    });
                    if (pd != null)
                    {
                        if (!string.IsNullOrEmpty(from))
                        {
                            from += ",";
                        }
                        from += pd.Id;
                        if (!string.IsNullOrEmpty(lFrom.Text))
                        {
                            lFrom.Text += ", ";
                        }
                        lFrom.Text += f;
                    }
                }
                if (!string.IsNullOrEmpty(from))
                {
                    s += " and wz.UserId in (" + from + ")";
                }
            }
            else
            {
                lFrom.Text = "от всех";
            }
            return(s);
        }
Exemplo n.º 17
0
        protected void AllZPrim(object sender, EventArgs e)
        {
            DayPrim.Visible = true;
            //  ReportTitle.Text = "Cобытия по закрепленным лифтам";
            using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                conn.Open();
                List <Data>   data = new List <Data>();
                App_Code.Base db   = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                List <string> lift = db.GetLiftId(_user);
                foreach (string _lift in lift)
                {
                    SqlCommand cmd = new SqlCommand();
                    if (_user != "Sargamonov")
                    {
                        s = "select wz.Id, wz.UserId, wz.[Date], ui.Family, ui.IO, e.Id, wz.Done, wz.[Text], wz.[LiftId], wz.Type, wz.Readed from WorkerZayavky wz " +
                            "join UserInfo ui on ui.UserId=wz.UserId " +
                            "join Events e on e.WZayavId=wz.Id " +
                            "where wz.Done=0 and wz.Readed=0 and wz.Type!=N'ПНР/РЭО' and wz.Type=N'замечания по лифтам' and wz.LiftId=@userlift";
                    }
                    else if (_user == "Sargamonov")
                    {
                        s = "select wz.Id, wz.UserId, wz.[Date], ui.Family, ui.IO, e.Id, wz.Done, wz.[Text], wz.[LiftId], wz.Type, wz.Readed from WorkerZayavky wz " +                      // "join Events e on e.ZayavId=wz.Id " +
                            "join UserInfo ui on ui.UserId=wz.UserId " +
                            "join Events e on e.WZayavId=wz.Id " +
                            "where wz.Done=0 and wz.Readed=0 and wz.Type=N'ПНР/РЭО' and wz.LiftId=@userlift";
                    }
                    cmd = new SqlCommand(s, conn);

                    cmd.Parameters.AddWithValue("userlift", _lift);
                    SqlDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        data.Add(new Data()
                        {
                            Title = " №" + " " + dr[5].ToString(),
                            Url   = "~/WZClose.aspx?wz=" + Int32.Parse(dr["Id"].ToString()),
                            Text1 = dr["Text"].ToString(),
                            Idi   = dr["LiftId"].ToString()
                        });
                    }
                    dr.Close();
                    List.DataSource = data;
                    List.DataBind();
                }
            }
            using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                conn.Open();
                List <Data>   data = new List <Data>();
                App_Code.Base db   = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                List <string> lift = db.GetLiftId(_user);
                foreach (string _lift in lift)
                {
                    SqlCommand cmd = new SqlCommand();
                    if (_user != "Sargamonov")
                    {
                        s = "select wz.Id, wz.UserId, wz.[Date], ui.Family, ui.IO, e.Id, wz.Done, wz.[Text], wz.[LiftId], wz.Type, wz.Readed from WorkerZayavky wz " +
                            "join UserInfo ui on ui.UserId=wz.UserId " +
                            "join Events e on e.WZayavId=wz.Id " +
                            "where wz.Done=0 and wz.Readed=1 and wz.Type!=N'ПНР/РЭО' and wz.Type=N'замечания по лифтам' and wz.LiftId=@userlift";
                    }
                    else if (_user == "Sargamonov")
                    {
                        s = "select wz.Id, wz.UserId, wz.[Date], ui.Family, ui.IO, e.Id, wz.Done, wz.[Text], wz.[LiftId], wz.Type, wz.Readed from WorkerZayavky wz " +                      // "join Events e on e.ZayavId=wz.Id " +
                            "join UserInfo ui on ui.UserId=wz.UserId " +
                            "join Events e on e.WZayavId=wz.Id " +
                            "where wz.Done=0 and wz.Readed=1 and wz.Type=N'ПНР/РЭО' and wz.LiftId=@userlift";
                    }
                    cmd = new SqlCommand(s, conn);

                    cmd.Parameters.AddWithValue("userlift", _lift);
                    SqlDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        data.Add(new Data()
                        {
                            Title = " №" + " " + dr[5].ToString(),
                            Url   = "~/WZClose.aspx?wz=" + Int32.Parse(dr["Id"].ToString()),
                            Text1 = dr["Text"].ToString(),
                            Idi   = dr["LiftId"].ToString()
                        });
                    }
                    dr.Close();
                    ListNA.DataSource = data;
                    ListNA.DataBind();
                }
            }
            using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                conn.Open();
                List <Data>   data = new List <Data>();
                App_Code.Base db   = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                List <string> lift = db.GetLiftId(_user);
                foreach (string _lift in lift)
                {
                    SqlCommand cmd = new SqlCommand();
                    if (_user != "Sargamonov")
                    {
                        s = "select wz.Id, wz.UserId, wz.[Date], ui.Family, ui.IO, e.Id, wz.Done, wz.[Text], wz.[LiftId], wz.Type, wz.Readed from WorkerZayavky wz " +
                            "join UserInfo ui on ui.UserId=wz.UserId " +
                            "join Events e on e.WZayavId=wz.Id " +
                            "where wz.Done=0 and wz.Readed=0 and wz.Type!=N'ПНР/РЭО' and wz.Type=N'запчасти и расходные материалы' and wz.LiftId=@userlift";
                    }
                    else if (_user == "Sargamonov")
                    {
                        s = "select wz.Id, wz.UserId, wz.[Date], ui.Family, ui.IO, e.Id, wz.Done, wz.[Text], wz.[LiftId], wz.Type, wz.Readed from WorkerZayavky wz " +                      // "join Events e on e.ZayavId=wz.Id " +
                            "join UserInfo ui on ui.UserId=wz.UserId " +
                            "join Events e on e.WZayavId=wz.Id " +
                            "where wz.Done=0 and wz.Readed=0 and wz.Type=N'запчасти и расходные материалы' and ui.Family=N'Саргамонов' and wz.LiftId=@userlift";
                    }
                    cmd = new SqlCommand(s, conn);

                    cmd.Parameters.AddWithValue("userlift", _lift);
                    SqlDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        data.Add(new Data()
                        {
                            Title = " №" + " " + dr[5].ToString(),
                            Url   = "~/WZClose.aspx?wz=" + Int32.Parse(dr["Id"].ToString()),
                            Text1 = dr["Text"].ToString(),
                            Idi   = dr["LiftId"].ToString()
                        });
                    }
                    dr.Close();
                    ListZap.DataSource = data;
                    ListZap.DataBind();
                }
            }
            using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                conn.Open();
                List <Data>   data = new List <Data>();
                App_Code.Base db   = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                List <string> lift = db.GetLiftId(_user);
                foreach (string _lift in lift)
                {
                    SqlCommand cmd = new SqlCommand();
                    if (_user != "Sargamonov")
                    {
                        s = "select wz.Id, wz.UserId, wz.[Date], ui.Family, ui.IO, e.Id, wz.Done, wz.[Text], wz.[LiftId], wz.Type, wz.Readed from WorkerZayavky wz " +
                            "join UserInfo ui on ui.UserId=wz.UserId " +
                            "join Events e on e.WZayavId=wz.Id " +
                            "where wz.Done=0 and wz.Readed=1 and wz.Type!=N'ПНР/РЭО' and wz.Type=N'запчасти и расходные материалы' and wz.LiftId=@userlift";
                    }
                    else if (_user == "Sargamonov")
                    {
                        s = "select wz.Id, wz.UserId, wz.[Date], ui.Family, ui.IO, e.Id, wz.Done, wz.[Text], wz.[LiftId], wz.Type, wz.Readed from WorkerZayavky wz " +                      // "join Events e on e.ZayavId=wz.Id " +
                            "join UserInfo ui on ui.UserId=wz.UserId " +
                            "join Events e on e.WZayavId=wz.Id " +
                            "where wz.Done=0 and wz.Readed=1 and wz.Type=N'запчасти и расходные материалы' and ui.Family=N'Саргамонов' and wz.LiftId=@userlift";
                    }
                    cmd = new SqlCommand(s, conn);

                    cmd.Parameters.AddWithValue("userlift", _lift);
                    SqlDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        data.Add(new Data()
                        {
                            Title = " №" + " " + dr[5].ToString(),
                            Url   = "~/WZClose.aspx?wz=" + Int32.Parse(dr["Id"].ToString()),
                            Text1 = dr["Text"].ToString(),
                            Idi   = dr["LiftId"].ToString()
                        });
                    }
                    dr.Close();
                    ListZapNA.DataSource = data;
                    ListZapNA.DataBind();
                }
            } using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                conn.Open();
                List <Data>   data = new List <Data>();
                App_Code.Base db   = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                List <string> lift = db.GetLiftId(_user);
                foreach (string _lift in lift)
                {
                    SqlCommand cmd = new SqlCommand();
                    if (_user != "Sargamonov")
                    {
                        s = "select wz.Id, wz.UserId, wz.[Date], ui.Family, ui.IO, e.Id, wz.Done, wz.[Text], wz.[LiftId], wz.Type, wz.Readed from WorkerZayavky wz " +
                            "join UserInfo ui on ui.UserId=wz.UserId " +
                            "join Events e on e.WZayavId=wz.Id " +
                            "where wz.Done=0 and wz.Readed=0 and wz.Type!=N'ПНР/РЭО' and wz.Type=N'инструменты и оборудование' and wz.LiftId=@userlift";
                    }
                    else if (_user == "Sargamonov")
                    {
                        s = "select wz.Id, wz.UserId, wz.[Date], ui.Family, ui.IO, e.Id, wz.Done, wz.[Text], wz.[LiftId], wz.Type, wz.Readed from WorkerZayavky wz " +
                            "join UserInfo ui on ui.UserId=wz.UserId " +
                            "join Events e on e.WZayavId=wz.Id " +
                            "where wz.Done=0 and wz.Readed=0 and wz.Type=N'инструменты и оборудование' and ui.Family=N'Саргамонов' and wz.LiftId=@userlift";
                    }
                    cmd = new SqlCommand(s, conn);

                    cmd.Parameters.AddWithValue("userlift", _lift);
                    SqlDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        data.Add(new Data()
                        {
                            Title = " №" + " " + dr[5].ToString(),
                            Url   = "~/WZClose.aspx?wz=" + Int32.Parse(dr["Id"].ToString()),
                            Text1 = dr["Text"].ToString(),
                            Idi   = dr["LiftId"].ToString()
                        });
                    }
                    dr.Close();
                    ListInst.DataSource = data;
                    ListInst.DataBind();
                }
            }
            using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                conn.Open();
                List <Data>   data = new List <Data>();
                App_Code.Base db   = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                List <string> lift = db.GetLiftId(_user);
                foreach (string _lift in lift)
                {
                    SqlCommand cmd = new SqlCommand();
                    if (_user != "Sargamonov")
                    {
                        s = "select wz.Id, wz.UserId, wz.[Date], ui.Family, ui.IO, e.Id, wz.Done, wz.[Text], wz.[LiftId], wz.Type, wz.Readed from WorkerZayavky wz " +
                            "join UserInfo ui on ui.UserId=wz.UserId " +
                            "join Events e on e.WZayavId=wz.Id " +
                            "where wz.Done=0 and wz.Readed=1 and wz.Type!=N'ПНР/РЭО' and wz.Type=N'инструменты и оборудование' and wz.LiftId=@userlift";
                    }
                    else if (_user == "Sargamonov")
                    {
                        s = "select wz.Id, wz.UserId, wz.[Date], ui.Family, ui.IO, e.Id, wz.Done, wz.[Text], wz.[LiftId], wz.Type, wz.Readed from WorkerZayavky wz " +                      // "join Events e on e.ZayavId=wz.Id " +
                            "join UserInfo ui on ui.UserId=wz.UserId " +
                            "join Events e on e.WZayavId=wz.Id " +
                            "where wz.Done=0 and wz.Readed=1 and wz.Type=N'инструменты и оборудование' and ui.Family=N'Саргамонов' and wz.LiftId=@userlift";
                    }
                    cmd = new SqlCommand(s, conn);

                    cmd.Parameters.AddWithValue("userlift", _lift);
                    SqlDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        data.Add(new Data()
                        {
                            Title = " №" + " " + dr[5].ToString(),
                            Url   = "~/WZClose.aspx?wz=" + Int32.Parse(dr["Id"].ToString()),
                            Text1 = dr["Text"].ToString(),
                            Idi   = dr["LiftId"].ToString()
                        });
                    }
                    dr.Close();
                    ListInstNA.DataSource = data;
                    ListInstNA.DataBind();
                }
            }
        }
Exemplo n.º 18
0
 protected void LiftId_SelectedIndexChanged(object sender, EventArgs e)
 {
     App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
     To.SelectedValue = db.GetWorker(LiftId.SelectedValue);
 }
Exemplo n.º 19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckAccount();

            _from = DateTime.Now.AddDays(-2);
            //   Label1.Text = "С " + _from.ToString();
            //      if (!IsPostBack)
            //      CheckAccount();

            //       _from = DateTime.Now.AddDays(-2);
            //                   Label1.Text = "С " + _from.ToString();

            /*    CurDate.Text = DateTime.Now.Date.ToLongDateString();
             *    CurHour.Text = DateTime.Now.Hour.ToString();
             *    CurMinute.Text = DateTime.Now.Minute.ToString(); */

            if (!IsPostBack)
            {
                using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    conn.Open();
                    // все события
                    SqlCommand cmd = new SqlCommand("select count(e.Id) from Events e " +
                                                    "where e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    //   Text2 = cmd.ExecuteScalar().ToString();
                    HyperLink2.Text = cmd.ExecuteScalar().ToString();
                    // срочные события - 2 дня
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Cansel=N'false' and e.DataId<=@date and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    Text2           = cmd.ExecuteScalar().ToString();
                    HyperLink3.Text = cmd.ExecuteScalar().ToString();
                    // все события без Акта
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.ZaprosMng=N'true' and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    //   Text4 = cmd.ExecuteScalar().ToString();
                    HyperLink5.Text = cmd.ExecuteScalar().ToString();
                    // срочные события без Акта
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.ZaprosMng=N'true' and e.DataId<=@date and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    Text3           = cmd.ExecuteScalar().ToString();
                    HyperLink6.Text = cmd.ExecuteScalar().ToString();
                    // все события с запросом manager
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.ZaprosKp=N'true' and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    // Text4 = cmd.ExecuteScalar().ToString();
                    HyperLink8.Text = cmd.ExecuteScalar().ToString();
                    // срочные события с запросом КП
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.ZaprosKp=N'true' and e.DataId<=@date and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    Text4           = cmd.ExecuteScalar().ToString();
                    HyperLink9.Text = cmd.ExecuteScalar().ToString();
                    // все события с ответом КП
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.KP=N'true' and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    // Text4 = cmd.ExecuteScalar().ToString();
                    HyperLink11.Text = cmd.ExecuteScalar().ToString();
                    // срочные события с ответом КП
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.KP=N'true' and e.DataId<=@date and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    Text5            = cmd.ExecuteScalar().ToString();
                    HyperLink12.Text = cmd.ExecuteScalar().ToString();
                    // все события с запросом счета
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.ZapBill=N'true' and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    // Text4 = cmd.ExecuteScalar().ToString();
                    HyperLink14.Text = cmd.ExecuteScalar().ToString();
                    // срочные события с запросом счета
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.ZapBill=N'true' and e.DataId<=@date and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    //   Text6 = cmd.ExecuteScalar().ToString();
                    HyperLink15.Text = cmd.ExecuteScalar().ToString();
                    // все события со  счетами
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Bill=N'true' and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    HyperLink17.Text = cmd.ExecuteScalar().ToString();
                    // срочные события со  счетами
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Bill=N'true' and e.DataId<=@date and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    HyperLink18.Text = cmd.ExecuteScalar().ToString();
                    // все события с ожиданием оплаты
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Payment=N'true' and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    HyperLink20.Text = cmd.ExecuteScalar().ToString();
                    // срочные события с ожиданием оплаты
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Payment=N'true' and e.DataId<=@date and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    HyperLink21.Text = cmd.ExecuteScalar().ToString();
                    // все события с ожиданием доставки
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Dostavka=N'true' and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    HyperLink35.Text = cmd.ExecuteScalar().ToString();
                    // срочные события с ожиданием доставки
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Dostavka=N'true' and e.DataId<=@date and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    HyperLink36.Text = cmd.ExecuteScalar().ToString();
                    // все события с ожиданием прихода
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Prihod=N'true' and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    HyperLink38.Text = cmd.ExecuteScalar().ToString();
                    // срочные события с ожиданием прихода
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Prihod=N'true' and e.DataId<=@date and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    HyperLink39.Text = cmd.ExecuteScalar().ToString();
                    // все события с ожиданием акта ВР
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.AktVR=N'true' and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    HyperLink41.Text = cmd.ExecuteScalar().ToString();
                    // срочные события с ожиданием акта ВР
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.AktVR=N'true' and e.DataId<=@date and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    HyperLink42.Text = cmd.ExecuteScalar().ToString();
                    // все события с ожиданием списания
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Spisanie=N'true' and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    HyperLink44.Text = cmd.ExecuteScalar().ToString();
                    // срочные события с ожиданием списания
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Spisanie=N'true' and e.DataId<=@date and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    HyperLink45.Text = cmd.ExecuteScalar().ToString();
                    //Блок ОДС ----------------------------------------------------------
                    cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                                         "join Users u on z.UserId=u.UserId " +
                                         "where z.Category=N'застревание' and z.Finish is null and u.UserName=@user", conn);
                    cmd.Parameters.AddWithValue("user", User.Identity.Name);
                    Text2 = cmd.ExecuteScalar().ToString();
                    //   HyperLink2.Text = cmd.ExecuteScalar().ToString();
                    // плановые работы
                    cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                                         "join Users u on z.UserId=u.UserId " +
                                         "join UsersInRoles uir on uir.UserId=z.UserId " +
                                         "join Roles r on r.RoleId=uir.RoleId and r.RoleName='ODS' " +
                                         "where z.Category=N'плановые работы' and z.Finish is null and u.UserName=@user", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    cmd.Parameters.AddWithValue("user", User.Identity.Name);
                    Text3 = cmd.ExecuteScalar().ToString();
                    //   HyperLink3.Text = cmd.ExecuteScalar().ToString();
                    // внеплановые ремонты
                    cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                                         "join Users u on z.UserId=u.UserId " +
                                         "join UsersInRoles uir on uir.UserId=z.UserId " +
                                         "join Roles r on r.RoleId=uir.RoleId and r.RoleName='ODS' " +
                                         "where z.Category=N'внеплановые ремонты' and z.Finish is null and u.UserName=@user", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    cmd.Parameters.AddWithValue("user", User.Identity.Name);
                    Text8 = cmd.ExecuteScalar().ToString();
                    //   HyperLink8.Text = cmd.ExecuteScalar().ToString();

                    cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                                         "join Users u on z.UserId=u.UserId " +
                                         "where z.Category=N'останов' and z.Finish is null and u.UserName=@user", conn);
                    cmd.Parameters.AddWithValue("user", User.Identity.Name);
                    Text4 = cmd.ExecuteScalar().ToString();
                    //   HyperLink4.Text = cmd.ExecuteScalar().ToString();
                    //заявки от заказчика
                    cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                                         "join UsersInRoles uir on uir.UserId=z.UserId " +
                                         "join Roles r on r.RoleId=uir.RoleId and r.RoleName='ODS' " +
                                         "join Users u on z.UserId=u.UserId " +
                                         "where z.Finish is null and z.Category=N'заявка'and u.UserName=@user", conn);
                    cmd.Parameters.AddWithValue("user", User.Identity.Name);
                    //   HyperLink5.Text = cmd.ExecuteScalar().ToString();
                    //отправленные заявки
                    cmd = new SqlCommand("select  count(z.Id) from Zayavky z " +
                                         "join UserInfo ui on ui.UserId=z.UserId " +
                                         "join UsersInRoles uir on uir.UserId=z.UserId " +
                                         "join Roles r on r.RoleId=uir.RoleId and r.RoleName='ODS' " +
                                         "join Users u on z.UserId=u.UserId " +
                                         "where z.Category=N'заявка' and z.Start>@date and u.UserName=@user", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    cmd.Parameters.AddWithValue("user", User.Identity.Name);
                    Text7 = cmd.ExecuteScalar().ToString();
                    cmd   = new SqlCommand("select count(z.Id) from Zayavky z " +
                                           "join UsersInRoles uir on uir.UserId=z.UserId " +
                                           "join Roles r on r.RoleId=uir.RoleId and r.RoleName='Cadry' " +
                                           "join Users u on z.UserId=u.UserId " +
                                           "where z.Category=N'заявка' and z.Finish is null and u.UserName=@user", conn);
                    cmd.Parameters.AddWithValue("user", User.Identity.Name);
                    Text6 = cmd.ExecuteScalar().ToString();
                    //   HyperLink6.Text = cmd.ExecuteScalar().ToString();
                    // подсчет активных событий
                    //   int all = int.Parse(HyperLink2.Text) + int.Parse(HyperLink3.Text) + int.Parse(HyperLink4.Text) + int.Parse(HyperLink6.Text)+ int.Parse(HyperLink8.Text);
                    int all = int.Parse(Text2) + int.Parse(Text3) + int.Parse(Text4) + int.Parse(Text6) + int.Parse(Text7) + int.Parse(Text8);
                    HyperLink29.Text = all.ToString();
                    App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                    List <App_Code.Base.StoppedLift> list = db.GetStoppedODSLifts(User.Identity.Name);
                    int total = db.GetODSLifts(User.Identity.Name);
                    Worked.Text  = (total - list.Count).ToString();
                    Stopped.Text = list.Count.ToString();
                }
            }
        }
Exemplo n.º 20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckAccount();

            if (!string.IsNullOrEmpty(Request["PlanId"]))
            {
                _planId = Int32.Parse(Request["PlanId"]);
            }
            if (!string.IsNullOrEmpty(Request["ret"]))
            {
                _retUrl = HttpUtility.HtmlDecode(Request["ret"]);
            }
            else
            {
                Grafik.Visible = false;
            }

            App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            _planIds = db.GetPlans(User.Identity.Name, _planId);
            _prim    = db.GetPrim(User.Identity.Name, _planId);
            List <TheN> n = new List <TheN>();

            foreach (DataRow dr in _prim.Rows)
            {
                n.Add(new TheN()
                {
                    N = (int)dr["N"]
                });
            }
            _data = db.GetReglamentWorks(_planId);
            _data.Columns.Add("bDone", Type.GetType("System.Boolean"));
            _data.Columns.Add("AddPrim", Type.GetType("System.String"));
            _data.Columns.Add("PrimExists", Type.GetType("System.String"));
            foreach (DataRow dr in _data.Rows)
            {
                if (dr["Done"] is DBNull || bool.Parse(dr["Done"].ToString()) == false)
                {
                    dr["bDone"] = false;
                }
                else
                {
                    dr["bDone"] = true;
                }
                //      if (dr["WorksId"] is DBNull) // было закомментировано
                dr["AddPrim"] = "~/AddPrim.aspx?PlanId=" + _planIds + "&ReglamentId=" + dr["ReglamentId"].ToString();
                //     else  // было закомментировано 2 стр.
                //       dr["AddPrim"] = "~/AddPrim.aspx?WorksId=" + dr["WorksId"].ToString() + "&PlanId=" + _planId + "&ReglamentId=" + dr["ReglamentId"].ToString();
                dr["PrimExists"] = "";
                if (!(dr["N"] is DBNull))
                {
                    int N = (int)dr["N"];
                    if (n.Find(delegate(TheN i)
                    {
                        return(i.N == N);
                    }) != null)
                    {
                        dr["PrimExists"] = "!!!";
                    }
                }
            }
            _liftsId = db.GetLiftsId(_planId);
            _liftId  = db.GetLiftId(_planId);

            /* string liftsId = string.Empty;// начало коммента
             * foreach (string s in _liftsId)
             *   if (string.IsNullOrEmpty(liftsId))
             *       liftsId = s;
             *   else
             *       liftsId += "," + s; */
            // конец коммента

            List <Data> data = new List <Data>();

            using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("select TpId from [Plan] where Id=@id", conn);
                cmd.Parameters.AddWithValue("id", _planId);
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    _TpId = dr["TpId"].ToString();
                }
                dr.Close();
            }
//
            using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                conn.Open();
                TpId.Text    = _TpId;
                LiftsId.Text = _liftId;
                SqlCommand cmd = new SqlCommand("select r.[Title] from [Reglament] r " +
                                                "where r.[TpId]=@rId", conn);

                /*     if (TpId.Text == "ТР")
                 *   cmd.Parameters.AddWithValue("rId", "ТР");
                 *   else if (TpId.Text == "ТР1")
                 *   cmd.Parameters.AddWithValue("rId", "ТР1");
                 *   else if (TpId.Text == "ТР2")
                 *   cmd.Parameters.AddWithValue("rId", "ТР2");
                 *   else if (TpId.Text == "ТР3")
                 *   cmd.Parameters.AddWithValue("rId", "ТР3");
                 *   else */
                cmd.Parameters.AddWithValue("rId", TpId.Text);
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    data.Add(new Data()
                    {
                        Title = dr["Title"].ToString()
                    });
                    Out.DataSource = data;
                    Out.DataBind();
                }
                dr.Close();
            }
//
            if (!IsPostBack)
            {
                ReglamentWorks.DataSource = _data;
                ReglamentWorks.DataBind();
                Msg.Text = string.Empty;
                List <Base.ZPrim> list = db.GetNotDonePrim(_liftId, Request.Url.ToString());
                ZPrim.DataSource = list;
                ZPrim.DataBind();
                using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("select Done from [Plan] where Id=@id", conn);
                    cmd.Parameters.AddWithValue("id", _planId);
                    object o = cmd.ExecuteScalar();
                    if (o != null)
                    {
                        Done.Checked = bool.Parse(o.ToString());
                    }
                    cmd = new SqlCommand("select Prn from [Plan] where Id=@id", conn);
                    cmd.Parameters.AddWithValue("id", _planId);
                    string op = cmd.ExecuteScalar().ToString();
                    if (op == "")
                    {
                        Prin.Checked = false;
                    }
                    else
                    {
                        Prin.Checked = bool.Parse(op.ToString());
                    }
                }
                if (User.Identity.Name == "Volodin" || User.Identity.Name == "Puzin" || User.Identity.Name == "manager")
                {
                    Prin.Visible = true; btnPrin.Visible = true;
                }
                if (TpId.Text == "ВР" && User.Identity.Name == "manager")
                {
                    AddBP.Visible = true; TextBox1.Visible = true; L1.Visible = true;
                }
            }
        }
Exemplo n.º 21
0
        /*      protected void VseRaboty(object sender, EventArgs e)
         *     {
         *         Zayavky.Text = "Все работы на " + DateTime.Now.ToShortDateString();
         *         if (!IsPostBack)
         *         {
         *             List<Data> data = new List<Data>();
         *
         *             if (User.Identity.Name == "Sargamonov")
         *             {
         *                 using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
         *                 {
         *                     conn.Open();
         *                     SqlCommand cmd = new SqlCommand("select z.Id, z.LiftId, z.[Text], e.Id, z.Category, z.Worker, z.Start, z.Status from Zayavky z " +
         *                     "join [Events] e on e.ZayavId=z.Id " +
         *                     "join WorkerLifts wl on wl.LiftId=z.LiftId " +
         *                     "join Users u on u.UserId=wl.UserId " +
         *                     "where u.UserName=@UserName and z.Category=N'ПНР/РЭО' and z.[Finish] is null ", conn);
         *                     cmd.Parameters.AddWithValue("UserName", User.Identity.Name);
         *                     SqlDataReader dr = cmd.ExecuteReader();
         *                     while (dr.Read())
         *                         data.Add(new Data()
         *                         {
         *                             Title = " №" + " " + dr[3].ToString(),
         *                             Url = "~/ZayavkaEdit.aspx?zId=" + Int32.Parse(dr["Id"].ToString()),
         *                             Text1 = dr["Text"].ToString(),
         *                             Idi = dr["LiftId"].ToString()
         *                         });
         *                     dr.Close();
         *                     ZayavkyList.DataSource = data;
         *                     ZayavkyList.DataBind();
         *                 }
         *             }
         *             else
         *             {
         *                 using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
         *                 {
         *                     conn.Open();
         *                     SqlCommand cmd = new SqlCommand("select z.Id, z.LiftId, z.[Text], e.Id, z.Category, z.Worker, z.Start, z.Status from Zayavky z " +
         *                    "join [Events] e on e.ZayavId=z.Id " +
         *                    "join WorkerLifts wl on wl.LiftId=z.LiftId " +
         *                    "join Users u on u.UserId=wl.UserId " +
         *                    "where u.UserName=@UserName and z.Category!=N'ПНР/РЭО' and z.[Finish] is null ", conn);
         *                     cmd.Parameters.AddWithValue("UserName", User.Identity.Name);
         *                     SqlDataReader dr = cmd.ExecuteReader();
         *                     while (dr.Read())
         *                         data.Add(new Data()
         *                         {
         *                             Title = " №" + " " + dr[3].ToString(),
         *                             Url = "~/ZayavkaEdit.aspx?zId=" + Int32.Parse(dr["Id"].ToString()),
         *                             Text1 = dr["Text"].ToString(),
         *                             Idi = dr["LiftId"].ToString()
         *                         });
         *                     dr.Close();
         *                     ZayavkyList.DataSource = data;
         *                     ZayavkyList.DataBind();
         *                 }
         *                 if (User.Identity.Name == "Sargamonov")
         *                 {
         *                     List<Data> data1 = new List<Data>(); // неактивные
         *                     using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
         *                     {
         *                         conn.Open();
         *                         SqlCommand cmd = new SqlCommand("select z.Id, z.LiftId, z.[Text], e.Id, z.Category, z.Worker, z.Start, z.Status from Zayavky z " +
         *                         "join [Events] e on e.ZayavId=z.Id " +
         *                         "join WorkerLifts wl on wl.LiftId=z.LiftId " +
         *                         "join Users u on u.UserId=wl.UserId " +
         *                         "where u.UserName=@UserName and z.Category=N'ПНР/РЭО' and z.[Finish]=1 and z.Status=N'false'", conn);
         *                         cmd.Parameters.AddWithValue("UserName", User.Identity.Name);
         *                         SqlDataReader dr = cmd.ExecuteReader();
         *                         while (dr.Read())
         *                             data1.Add(new Data()
         *                             {
         *                                 Title = " №" + " " + dr[3].ToString(),
         *                                 Url = "~/ZayavkaEdit.aspx?zId=" + Int32.Parse(dr["Id"].ToString()),
         *                                 Text1 = dr["Text"].ToString(),
         *                                 Idi = dr["LiftId"].ToString()
         *                             });
         *                         dr.Close();
         *                         ZayavkyNA.DataSource = data1;
         *                         ZayavkyNA.DataBind();
         *                     }
         *                 }
         *                 else
         *                 {
         *                     List<Data> data1 = new List<Data>(); // неактивные
         *                     using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
         *                     {
         *                         conn.Open();
         *                         SqlCommand cmd = new SqlCommand("select z.Id, z.LiftId, z.[Text], e.Id, z.Category, z.Worker, z.Start, z.Status from Zayavky z " +
         *                        "join [Events] e on e.ZayavId=z.Id " +
         *                        "join WorkerLifts wl on wl.LiftId=z.LiftId " +
         *                        "join Users u on u.UserId=wl.UserId " +
         *                        "where u.UserName=@UserName and z.Category!=N'ПНР/РЭО' and z.[Finish]=1 and z.Status=N'false' ", conn);
         *                         cmd.Parameters.AddWithValue("UserName", User.Identity.Name);
         *                         SqlDataReader dr = cmd.ExecuteReader();
         *                         while (dr.Read())
         *                             data1.Add(new Data()
         *                             {
         *                                 Title = " №" + " " + dr[3].ToString(),
         *                                 Url = "~/ZayavkaEdit.aspx?zId=" + Int32.Parse(dr["Id"].ToString()),
         *                                 Text1 = dr["Text"].ToString(),
         *                                 Idi = dr["LiftId"].ToString()
         *                             });
         *                         dr.Close();
         *                         ZayavkyNA.DataSource = data1;
         *                         ZayavkyNA.DataBind();
         *                     }
         *                     using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
         *                     {
         *                         conn.Open();
         *                         List<Data> dat = new List<Data>();
         *                         SqlCommand cmd = new SqlCommand("select wz.Id, wz.UserId, wz.[Date], ui.Family, ui.IO, e.Id, wz.Done, wz.[Text], wz.[LiftId], wz.Readed from WorkerZayavky wz " +
         *                             "join UserInfo ui on ui.UserId=wz.UserId " +
         *                             //   "join WorkerLifts wl on wl.UserId=wz.UserId " +
         *                             "join Users u on wz.UserId=u.UserId " +
         *                             "join Events e on e.WZayavId=wz.Id " +
         *                             "where u.UserName=@user and wz.Done=0 and wz.Readed=0", conn);
         *                         cmd.Parameters.AddWithValue("user", User.Identity.Name);
         *                         SqlDataReader dr = cmd.ExecuteReader();
         *                         while (dr.Read())
         *                             dat.Add(new Data()
         *                             {
         *                                 Title = Title = " №" + " " + dr[5].ToString(),
         *                                 Url = "~/WZClose.aspx?wz=" + Int32.Parse(dr["Id"].ToString()),
         *                                 Text1 = dr["Text"].ToString(),
         *                                 Idi = dr["LiftId"].ToString()
         *                             });
         *                         dr.Close();
         *                         List.DataSource = dat;
         *                         List.DataBind();
         *                     }
         *                     using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
         *                     {
         *                         conn.Open();
         *                         List<Data> dat = new List<Data>();
         *                         SqlCommand cmd = new SqlCommand("select wz.Id, wz.UserId, wz.[Date], ui.Family, ui.IO, e.Id, wz.Done, wz.[Text], wz.[LiftId], wz.Readed from WorkerZayavky wz " +
         *                             "join UserInfo ui on ui.UserId=wz.UserId " +
         *                             //   "join WorkerLifts wl on wl.UserId=wz.UserId " +
         *                             "join Users u on wz.UserId=u.UserId " +
         *                             "join Events e on e.WZayavId=wz.Id " +
         *                             "where u.UserName=@user and wz.Done=0 and wz.Readed=1", conn);
         *                         cmd.Parameters.AddWithValue("user", User.Identity.Name);
         *                         SqlDataReader dr = cmd.ExecuteReader();
         *                         while (dr.Read())
         *                             dat.Add(new Data()
         *                             {
         *                                 Title = Title = " №" + " " + dr[5].ToString(),
         *                                 Url = "~/WZClose.aspx?wz=" + Int32.Parse(dr["Id"].ToString()),
         *                                 Text1 = dr["Text"].ToString(),
         *                                 Idi = dr["LiftId"].ToString()
         *                             });
         *                         dr.Close();
         *                         ListNA.DataSource = dat;
         *                         ListNA.DataBind();
         *                     }
         *                 }
         *             }
         *         }
         *     }
         */
        void BindTpPlan()
        {
            App_Code.Base db   = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            DateTime      date = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);

            _monthPlan = db.GetPlan(User.Identity.Name, date, date.AddMonths(1).AddSeconds(-1));
            DataTable dt = db.GetTpPlan(User.Identity.Name, IdUM.SelectedValue, date, date.AddMonths(1).AddSeconds(-1));

            _ltd = new List <TpData>();
            foreach (DataRow dr in dt.Rows)
            {
                DateTime d1 = new DateTime(), d2 = new DateTime();
                if (FindLiftTp(dr["LiftId"].ToString(), dr["TpId"].ToString(), out d1, out d2))
                {
                    date = d1;
                }
                else
                {
                    date = DateTime.MinValue;
                }
                TpData td = new TpData()
                {
                    Address = dr["Ttx"].ToString(),
                    Day     = date,
                    IdL     = dr["IdL"].ToString(),
                    TpId    = dr["TpId"].ToString(),
                    LiftId  = dr["LiftId"].ToString()
                };
                if (td.Day != DateTime.MinValue)
                {
                    td.Date = td.Day.ToString().Substring(0, 16);
                    List <DayPlan> ldp = GetDayPlan(td.Day);

                    #region MyRegion
                    string tpId = GetTp(8, td.LiftId, ldp);
                    if (string.IsNullOrEmpty(tpId))
                    {
                        td.H08    = "";
                        td.H08url = "~/Planning.aspx?liftId=" + HttpUtility.HtmlEncode(td.LiftId) +
                                    "&user="******"&tpId=" + HttpUtility.HtmlEncode(td.TpId) + "&date=" +
                                    HttpUtility.HtmlEncode((new DateTime(td.Day.Year, td.Day.Month, td.Day.Day, 8, 0, 0).ToString()));
                    }
                    else
                    {
                        td.H08 = tpId;
                    }
                    tpId = GetTp(9, td.LiftId, ldp);
                    if (string.IsNullOrEmpty(tpId))
                    {
                        td.H09    = "";
                        td.H09url = "~/Planning.aspx?liftId=" + HttpUtility.HtmlEncode(td.LiftId) +
                                    "&user="******"&tpId=" + HttpUtility.HtmlEncode(td.TpId) + "&date=" +
                                    HttpUtility.HtmlEncode((new DateTime(td.Day.Year, td.Day.Month, td.Day.Day, 9, 0, 0).ToString()));
                    }
                    else
                    {
                        td.H09 = tpId;
                    }
                    tpId = GetTp(10, td.LiftId, ldp);
                    if (string.IsNullOrEmpty(tpId))
                    {
                        td.H10    = "";
                        td.H10url = "~/Planning.aspx?liftId=" + HttpUtility.HtmlEncode(td.LiftId) +
                                    "&user="******"&tpId=" + HttpUtility.HtmlEncode(td.TpId) + "&date=" +
                                    HttpUtility.HtmlEncode((new DateTime(td.Day.Year, td.Day.Month, td.Day.Day, 10, 0, 0).ToString()));
                    }
                    else
                    {
                        td.H10 = tpId;
                    }
                    tpId = GetTp(11, td.LiftId, ldp);
                    if (string.IsNullOrEmpty(tpId))
                    {
                        td.H11    = "";
                        td.H11url = "~/Planning.aspx?liftId=" + HttpUtility.HtmlEncode(td.LiftId) +
                                    "&user="******"&tpId=" + HttpUtility.HtmlEncode(td.TpId) + "&date=" +
                                    HttpUtility.HtmlEncode((new DateTime(td.Day.Year, td.Day.Month, td.Day.Day, 11, 0, 0).ToString()));
                    }
                    else
                    {
                        td.H11 = tpId;
                    }
                    tpId = GetTp(12, td.LiftId, ldp);
                    if (string.IsNullOrEmpty(tpId))
                    {
                        td.H12    = "";
                        td.H12url = "~/Planning.aspx?liftId=" + HttpUtility.HtmlEncode(td.LiftId) +
                                    "&user="******"&tpId=" + HttpUtility.HtmlEncode(td.TpId) + "&date=" +
                                    HttpUtility.HtmlEncode((new DateTime(td.Day.Year, td.Day.Month, td.Day.Day, 12, 0, 0).ToString()));
                    }
                    else
                    {
                        td.H12 = tpId;
                    }
                    tpId = GetTp(13, td.LiftId, ldp);
                    if (string.IsNullOrEmpty(tpId))
                    {
                        td.H13    = "";
                        td.H13url = "~/Planning.aspx?liftId=" + HttpUtility.HtmlEncode(td.LiftId) +
                                    "&user="******"&tpId=" + HttpUtility.HtmlEncode(td.TpId) + "&date=" +
                                    HttpUtility.HtmlEncode((new DateTime(td.Day.Year, td.Day.Month, td.Day.Day, 13, 0, 0).ToString()));
                    }
                    else
                    {
                        td.H13 = tpId;
                    }
                    tpId = GetTp(14, td.LiftId, ldp);
                    if (string.IsNullOrEmpty(tpId))
                    {
                        td.H14    = "";
                        td.H14url = "~/Planning.aspx?liftId=" + HttpUtility.HtmlEncode(td.LiftId) +
                                    "&user="******"&tpId=" + HttpUtility.HtmlEncode(td.TpId) + "&date=" +
                                    HttpUtility.HtmlEncode((new DateTime(td.Day.Year, td.Day.Month, td.Day.Day, 14, 0, 0).ToString()));
                    }
                    else
                    {
                        td.H14 = tpId;
                    }
                    tpId = GetTp(15, td.LiftId, ldp);
                    if (string.IsNullOrEmpty(tpId))
                    {
                        td.H15    = "";
                        td.H15url = "~/Planning.aspx?liftId=" + HttpUtility.HtmlEncode(td.LiftId) +
                                    "&user="******"&tpId=" + HttpUtility.HtmlEncode(td.TpId) + "&date=" +
                                    HttpUtility.HtmlEncode((new DateTime(td.Day.Year, td.Day.Month, td.Day.Day, 15, 0, 0).ToString()));
                    }
                    else
                    {
                        td.H15 = tpId;
                    }
                    tpId = GetTp(16, td.LiftId, ldp);
                    if (string.IsNullOrEmpty(tpId))
                    {
                        td.H16    = "";
                        td.H16url = "~/Planning.aspx?liftId=" + HttpUtility.HtmlEncode(td.LiftId) +
                                    "&user="******"&tpId=" + HttpUtility.HtmlEncode(td.TpId) + "&date=" +
                                    HttpUtility.HtmlEncode((new DateTime(td.Day.Year, td.Day.Month, td.Day.Day, 16, 0, 0).ToString()));
                    }
                    else
                    {
                        td.H16 = tpId;
                    }
                    tpId = GetTp(17, td.LiftId, ldp);
                    if (string.IsNullOrEmpty(tpId))
                    {
                        td.H17    = "";
                        td.H17url = "~/Planning.aspx?liftId=" + HttpUtility.HtmlEncode(td.LiftId) +
                                    "&user="******"&tpId=" + HttpUtility.HtmlEncode(td.TpId) + "&date=" +
                                    HttpUtility.HtmlEncode((new DateTime(td.Day.Year, td.Day.Month, td.Day.Day, 17, 0, 0).ToString()));
                    }
                    else
                    {
                        td.H17 = tpId;
                    }
                    tpId = GetTp(18, td.LiftId, ldp);
                    if (string.IsNullOrEmpty(tpId))
                    {
                        td.H18    = "";
                        td.H18url = "~/Planning.aspx?liftId=" + HttpUtility.HtmlEncode(td.LiftId) +
                                    "&user="******"&tpId=" + HttpUtility.HtmlEncode(td.TpId) + "&date=" +
                                    HttpUtility.HtmlEncode((new DateTime(td.Day.Year, td.Day.Month, td.Day.Day, 18, 0, 0).ToString()));
                    }
                    else
                    {
                        td.H18 = tpId;
                    }
                    tpId = GetTp(19, td.LiftId, ldp);
                    if (string.IsNullOrEmpty(tpId))
                    {
                        td.H19    = "";
                        td.H19url = "~/Planning.aspx?liftId=" + HttpUtility.HtmlEncode(td.LiftId) +
                                    "&user="******"&tpId=" + HttpUtility.HtmlEncode(td.TpId) + "&date=" +
                                    HttpUtility.HtmlEncode((new DateTime(td.Day.Year, td.Day.Month, td.Day.Day, 19, 0, 0).ToString()));
                    }
                    else
                    {
                        td.H19 = tpId;
                    }
                    tpId = GetTp(20, td.LiftId, ldp);
                    if (string.IsNullOrEmpty(tpId))
                    {
                        td.H20    = "";
                        td.H20url = "~/Planning.aspx?liftId=" + HttpUtility.HtmlEncode(td.LiftId) +
                                    "&user="******"&tpId=" + HttpUtility.HtmlEncode(td.TpId) + "&date=" +
                                    HttpUtility.HtmlEncode((new DateTime(td.Day.Year, td.Day.Month, td.Day.Day, 20, 0, 0).ToString()));
                    }
                    else
                    {
                        td.H20 = tpId;
                    }
                    #endregion
                }
                _ltd.Add(td);
            }
        }
Exemplo n.º 22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Request["zId"]))
            {
                // if (!string.IsNullOrEmpty(Request["zId"]) && !IsPostBack)
                Response.Redirect("~/About.aspx");
            }
            _wz = Int32.Parse(Request["zId"]);
            if (User.Identity.Name != "ODS14")
            {
                Treg.Visible = false; Tzak.Visible = false;
            }
            if (!IsPostBack)
            {
                App_Code.Base db   = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                DataTable     data = db.GetEvent(_wz);
                if (data.Rows.Count < 1)
                {
                    Response.Redirect("~/About.aspx");
                }
                Id.Text     = _wz.ToString();
                Sourse.Text = data.Rows[0]["Sourse"].ToString();
                Text1.Text  = data.Rows[0]["Sourse"].ToString();
                IO.Text     = data.Rows[0]["IO"].ToString();
                DataId.Text = data.Rows[0]["DataId"].ToString();
                dateReg     = ((DateTime)data.Rows[0]["DataId"]);
                if (!string.IsNullOrEmpty(data.Rows[0]["DataId"].ToString()))
                {
                    yyy  = ((DateTime)data.Rows[0]["DataId"]).Year.ToString();
                    ddd  = ((DateTime)data.Rows[0]["DataId"]).Day.ToString();
                    momo = ((DateTime)data.Rows[0]["DataId"]).Month.ToString();
                    hhh  = ((DateTime)data.Rows[0]["DataId"]).Hour.ToString();
                    mmm  = ((DateTime)data.Rows[0]["DataId"]).Minute.ToString();
                }
                RegistrId.Text = data.Rows[0]["RegistrId"].ToString();
                LiftId.Text    = data.Rows[0]["LiftId"].ToString();
                TextBox4.Text  = data.Rows[0]["LiftId"].ToString();
                TypeId.Text    = data.Rows[0]["TypeId"].ToString();
                EventId.Text   = data.Rows[0]["EventId"].ToString();
                Text.Text      = data.Rows[0]["EventId"].ToString();
                ToApp.Text     = data.Rows[0]["ToApp"].ToString();
                Text2.Text     = data.Rows[0]["ToApp"].ToString();
                DateToApp.Text = data.Rows[0]["DateToApp"].ToString();
                if (!string.IsNullOrEmpty(data.Rows[0]["DateToApp"].ToString()))
                {
                    yyy1  = ((DateTime)data.Rows[0]["DateToApp"]).Year.ToString();
                    ddd1  = ((DateTime)data.Rows[0]["DateToApp"]).Day.ToString();
                    momo1 = ((DateTime)data.Rows[0]["DateToApp"]).Month.ToString();
                    hhh1  = ((DateTime)data.Rows[0]["DateToApp"]).Hour.ToString();
                    mmm1  = ((DateTime)data.Rows[0]["DateToApp"]).Minute.ToString();
                }
                Who.Text     = data.Rows[0]["Who"].ToString();
                Comment.Text = data.Rows[0]["Comment"].ToString();
                Text5.Text   = data.Rows[0]["Prim"].ToString();
                Prim.Text    = data.Rows[0]["Prim"].ToString();
                DateWho.Text = data.Rows[0]["DateWho"].ToString();
                //   TextBox3.Text = data.Rows[0]["DateWho"].ToString();
                //   if (string.IsNullOrEmpty(TextBox3.Text))
                //   TextBox3.Text = Convert.ToString(DateTime.Now);
                string   d = string.Empty;
                string   d2 = string.Empty, t2 = string.Empty;
                TimeSpan pr = DateTime.Now - ((DateTime)data.Rows[0]["DataId"]);
                if (!(data.Rows[0]["DateWho"] is DBNull))
                {
                    d2 = ((DateTime)data.Rows[0]["DateWho"]).Date.ToString();
                    t2 = ((DateTime)data.Rows[0]["DateWho"]).TimeOfDay.ToString();
                    pr = ((DateTime)data.Rows[0]["DateWho"]) - ((DateTime)data.Rows[0]["DataId"]);
                }
                if (!(data.Rows[0]["DateToApp"] is DBNull))
                {
                    d = ((DateTime)data.Rows[0]["DateToApp"]).ToString();
                }
                string prostoy = ((int)pr.TotalDays).ToString() + " " + pr.Hours.ToString() + ":" +
                                 pr.Minutes.ToString();
                Timing.Text = prostoy;
                {
                    yyy2  = DateTime.Now.Year.ToString();
                    ddd2  = DateTime.Now.Day.ToString();
                    momo2 = DateTime.Now.Month.ToString();
                    hhh2  = DateTime.Now.Hour.ToString();
                    mmm2  = DateTime.Now.Minute.ToString();
                }
            }
            //Год/месяц/день
            List <string> yy = new List <string>()
            {
                yyy, "2016", "2017", "2018", "2019", "2020"
            };

            if (!IsPostBack)
            {
                YY.DataSource = yy;
                YY.DataBind();
                YY.SelectedIndex = 0;
            }
            List <string> yy1 = new List <string>()
            {
                yyy1, "2016", "2017", "2018", "2019", "2020"
            };

            if (!IsPostBack)
            {
                YY1.DataSource = yy1;
                YY1.DataBind();
                YY1.SelectedIndex = 0;
            }
            List <string> yy2 = new List <string>()
            {
                yyy2, "2016", "2017", "2018", "2019", "2020"
            };

            if (!IsPostBack)
            {
                YY2.DataSource = yy2;
                YY2.DataBind();
                YY2.SelectedIndex = 0;
            }
            List <string> mo = new List <string>()
            {
                momo, "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"
            };

            if (!IsPostBack)
            {
                MO.DataSource = mo;
                MO.DataBind();
                MO.SelectedIndex = 0;
            }
            List <string> mo1 = new List <string>()
            {
                momo1, "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"
            };

            if (!IsPostBack)
            {
                MO1.DataSource = mo1;
                MO1.DataBind();
                MO1.SelectedIndex = 0;
            }
            List <string> mo2 = new List <string>()
            {
                momo2, "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"
            };

            if (!IsPostBack)
            {
                MO2.DataSource = mo2;
                MO2.DataBind();
                MO2.SelectedIndex = 0;
            }
            List <string> dd = new List <string>()
            {
                ddd, "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"
            };

            if (!IsPostBack)
            {
                DD.DataSource = dd;
                DD.DataBind();
                DD.SelectedIndex = 0;
            }
            List <string> dd1 = new List <string>()
            {
                ddd1, "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"
            };

            if (!IsPostBack)
            {
                DD1.DataSource = dd1;
                DD1.DataBind();
                DD1.SelectedIndex = 0;
            }
            List <string> dd2 = new List <string>()
            {
                ddd2, "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"
            };

            if (!IsPostBack)
            {
                DD2.DataSource = dd2;
                DD2.DataBind();
                DD2.SelectedIndex = 0;
            }

            //Часы/минуты
            List <string> hh = new List <string>()
            {
                hhh, "0", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"
            };

            if (!IsPostBack)
            {
                HH.DataSource = hh;
                HH.DataBind();
                HH.SelectedIndex = 0;
            }
            List <string> hh1 = new List <string>()
            {
                hhh1, "0", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"
            };

            if (!IsPostBack)
            {
                HH1.DataSource = hh1;
                HH1.DataBind();
                HH1.SelectedIndex = 0;
            }
            List <string> hh2 = new List <string>()
            {
                hhh2, "0", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"
            };

            if (!IsPostBack)
            {
                HH2.DataSource = hh2;
                HH2.DataBind();
                HH2.SelectedIndex = 0;
            }
            List <string> mm = new List <string>()
            {
                mmm, "05", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "00"
            };

            if (!IsPostBack)
            {
                MM.DataSource = mm;
                MM.DataBind();
                MM.SelectedIndex = 0;
            }
            List <string> mm1 = new List <string>()
            {
                mmm1, "05", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "00"
            };

            if (!IsPostBack)
            {
                MM1.DataSource = mm1;
                MM1.DataBind();
                MM1.SelectedIndex = 0;
            }
            List <string> mm2 = new List <string>()
            {
                mmm2, "05", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "00"
            };

            if (!IsPostBack)
            {
                MM2.DataSource = mm2;
                MM2.DataBind();
                MM2.SelectedIndex = 0;
            }

            //Диспетчер
            using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand("select p.surname, p.name, p.midlename from People p " +
                                                "where p.comments=@user and p.specialty=N'диспетчер'", conn);

                cmd.Parameters.AddWithValue("user", User.Identity.Name);

                List <string> iodisp = new List <string>()
                {
                    IO.Text
                };
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    iodisp.Add(dr[0].ToString() + " " + dr[1].ToString() + " " + dr[2].ToString());
                }
                dr.Close();
                if (!IsPostBack)
                {
                    FIO.DataSource = iodisp;
                    FIO.DataBind();
                    FIO.SelectedIndex = 0;
                    Fdr.Visible       = false;
                    TextBox5.Text     = IO.Text;
                }
            }
            //Механик
            List <string> worker = new List <string>()
            {
                ToApp.Text
            };

            if (!IsPostBack)
            {
                Workers.DataSource  = worker;
                Workers0.DataSource = worker;
                Workers.DataBind();
                Workers0.DataBind();
                Workers.SelectedIndex  = 0;
                Workers0.SelectedIndex = 0;
                Worker_TextChanged(this, EventArgs.Empty);
            }

            if (RegistrId.Text == "Эксплуатация лифтов")
            {
                Wrk.Visible   = true;
                Wrk0.Visible  = true;
                Text2.Visible = false;
                Text3.Visible = false;
            }
            else
            {
                Wrk.Visible   = false;
                Wrk0.Visible  = false;
                Text2.Visible = true;
                Text3.Visible = true;
            }
        }
Exemplo n.º 23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckAccount();

            _from       = DateTime.Now.AddDays(-2);
            Label1.Text = "С " + _from.ToString();
            //  Label2.Text = "С " + _from.ToString();
            if (!IsPostBack)
            {
                using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    conn.Open();

                    SqlCommand cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                                                    "where z.Category=N'застревание' and z.Start>@date", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    HyperLink1.Text = cmd.ExecuteScalar().ToString();

                    cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                                         "where z.Category=N'застревание' and z.Finish is null", conn);
                    HyperLink2.Text = cmd.ExecuteScalar().ToString();

                    cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                                         "where z.Category=N'останов' and z.Start>@date", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    HyperLink3.Text = cmd.ExecuteScalar().ToString();

                    cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                                         "where z.Category=N'останов' and z.Finish is null", conn);
                    HyperLink4.Text = cmd.ExecuteScalar().ToString();

                    cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                                         "join UsersInRoles uir on uir.UserId=z.UserId " +
                                         "join Roles r on r.RoleId=uir.RoleId and r.RoleName='ODS' " +
                                         "where z.Category=N'заявка' and z.Start>@date", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    HyperLink5.Text = cmd.ExecuteScalar().ToString();

                    cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                                         "join UsersInRoles uir on uir.UserId=z.UserId " +
                                         "join Roles r on r.RoleId=uir.RoleId and r.RoleName='ODS' " +
                                         "where z.Category=N'заявка' and z.Finish is null", conn);
                    HyperLink6.Text = cmd.ExecuteScalar().ToString();

                    cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                                         "join UsersInRoles uir on uir.UserId=z.UserId " +
                                         "join Roles r on r.RoleId=uir.RoleId and r.RoleName='Manager' " +
                                         "where z.Category=N'заявка' and z.Start>@date", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    HyperLink7.Text = cmd.ExecuteScalar().ToString();

                    cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                                         "join UsersInRoles uir on uir.UserId=z.UserId " +
                                         "join Roles r on r.RoleId=uir.RoleId and r.RoleName='Manager' " +
                                         "where z.Category=N'заявка' and z.Finish is null", conn);
                    HyperLink8.Text = cmd.ExecuteScalar().ToString();

                    cmd = new SqlCommand("select count(wz.Id) from WorkerZayavky wz " +
                                         "where wz.[Date]>@date", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    HyperLink9.Text = cmd.ExecuteScalar().ToString();

                    cmd = new SqlCommand("select count(wz.Id) from WorkerZayavky wz " +
                                         "where wz.Done=0", conn);
                    HyperLink10.Text = cmd.ExecuteScalar().ToString();
                    cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                                         "join UsersInRoles uir on uir.UserId=z.UserId " +
                                         "join Roles r on r.RoleId=uir.RoleId and r.RoleName='ODS' " +
                                         "where z.Category=N'плановые работы' and z.Finish is null", conn);
                    HyperLink11.Text = cmd.ExecuteScalar().ToString();
                    cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                                         "join UsersInRoles uir on uir.UserId=z.UserId " +
                                         "join Roles r on r.RoleId=uir.RoleId and r.RoleName='ODS' " +
                                         "where z.Category=N'внеплановые ремонты' and z.Finish is null", conn);
                    HyperLink12.Text = cmd.ExecuteScalar().ToString();
                    // все события
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    //   Text2 = cmd.ExecuteScalar().ToString();
                    HyperLink47.Text = cmd.ExecuteScalar().ToString();
                    // срочные события - 2 дня
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Cansel=N'false' and e.DataId<=@date and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    //   Text2 = cmd.ExecuteScalar().ToString();
                    HyperLink48.Text = cmd.ExecuteScalar().ToString();
                    // все события без Акта
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.ZaprosMng=N'true' and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    //   Text4 = cmd.ExecuteScalar().ToString();
                    HyperLink50.Text = cmd.ExecuteScalar().ToString();
                    // срочные события без Акта
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.ZaprosMng=N'true' and e.DataId<=@date and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    //    Text3 = cmd.ExecuteScalar().ToString();
                    HyperLink51.Text = cmd.ExecuteScalar().ToString();
                    // все события с запросом КП
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.ZaprosKp=N'true' and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    // Text4 = cmd.ExecuteScalar().ToString();
                    HyperLink53.Text = cmd.ExecuteScalar().ToString();
                    // срочные события с запросом КП
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.ZaprosKp=N'true' and e.DataId<=@date and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    //    Text4 = cmd.ExecuteScalar().ToString();
                    HyperLink54.Text = cmd.ExecuteScalar().ToString();
                    // все события с ответом КП
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.KP=N'true' and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    // Text4 = cmd.ExecuteScalar().ToString();
                    HyperLink56.Text = cmd.ExecuteScalar().ToString();
                    // срочные события с ответом КП
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.KP=N'true' and e.DataId<=@date and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    //    Text5 = cmd.ExecuteScalar().ToString();
                    HyperLink57.Text = cmd.ExecuteScalar().ToString();
                    // все события с запросом счета
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.ZapBill=N'true' and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    // Text4 = cmd.ExecuteScalar().ToString();
                    HyperLink59.Text = cmd.ExecuteScalar().ToString();
                    // срочные события с запросом счета
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.ZapBill=N'true' and e.DataId<=@date and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    //   Text6 = cmd.ExecuteScalar().ToString();
                    HyperLink60.Text = cmd.ExecuteScalar().ToString();
                    // все события со  счетами
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Bill=N'true' and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    HyperLink62.Text = cmd.ExecuteScalar().ToString();
                    // срочные события со  счетами
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Bill=N'true' and e.DataId<=@date and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    HyperLink63.Text = cmd.ExecuteScalar().ToString();
                    // все события с ожиданием оплаты
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Payment=N'true' and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    HyperLink20.Text = cmd.ExecuteScalar().ToString();
                    // срочные события с ожиданием оплаты
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Payment=N'true' and e.DataId<=@date and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    HyperLink21.Text = cmd.ExecuteScalar().ToString();
                    // все события с ожиданием доставки
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Dostavka=N'true' and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    HyperLink35.Text = cmd.ExecuteScalar().ToString();
                    // срочные события с ожиданием доставки
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Dostavka=N'true' and e.DataId<=@date and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    HyperLink36.Text = cmd.ExecuteScalar().ToString();
                    // все события с ожиданием прихода
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Prihod=N'true' and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    HyperLink38.Text = cmd.ExecuteScalar().ToString();
                    // срочные события с ожиданием прихода
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Prihod=N'true' and e.DataId<=@date and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    HyperLink39.Text = cmd.ExecuteScalar().ToString();
                    // все события с ожиданием акта ВР
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.AktVR=N'true' and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    HyperLink41.Text = cmd.ExecuteScalar().ToString();
                    // срочные события с ожиданием акта ВР
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.AktVR=N'true' and e.DataId<=@date and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    HyperLink42.Text = cmd.ExecuteScalar().ToString();
                    // все события с ожиданием списания
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Spisanie=N'true' and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    HyperLink44.Text = cmd.ExecuteScalar().ToString();
                    // срочные события с ожиданием списания
                    cmd = new SqlCommand("select count(e.Id) from Events e " +
                                         "where e.Spisanie=N'true' and e.DataId<=@date and e.Cansel=N'false' and RegistrId=N'Эксплуатация лифтов'", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    HyperLink45.Text = cmd.ExecuteScalar().ToString();
                    // ReadFromInternet sms = new ReadFromInternet();
                    // sms.MakeRequest();
                    App_Code.Base           db    = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                    List <App_Code.Base.UM> lifts = db.GetUM();
                    Lifts.DataSource = lifts;
                    Lifts.DataBind();

                    List <App_Code.Base.LiftPrim> liftPrim  = db.GetLiftPrim();
                    List <App_Code.Base.LiftPrim> liftZPrim = db.GetLiftZPrim();
                    foreach (App_Code.Base.LiftPrim i in liftZPrim)
                    {
                        int n = liftPrim.FindIndex(delegate(App_Code.Base.LiftPrim lp)
                        {
                            return(lp.IdUM == i.IdUM);
                        });
                        if (n >= 0)
                        {
                            liftPrim[n].N = (int.Parse(liftPrim[n].N) + int.Parse(i.N)).ToString();
                        }
                        else
                        {
                            liftPrim.Add(i);
                        }
                    }
                    liftPrim.Sort(delegate(App_Code.Base.LiftPrim lp1, App_Code.Base.LiftPrim lp2)
                    {
                        return(string.Compare(lp1.IdUM, lp2.IdUM));
                    });
                    LiftPrim.DataSource = liftPrim;
                    LiftPrim.DataBind();
                }
            }
        }
Exemplo n.º 24
0
 void FillLabels()
 {
     lPrinyalDate.Text = " с " + CalendarStart.SelectedDate.ToLongDateString() + " по " +
                         CalendarStartEnd.SelectedDate.ToLongDateString();
     if (HourStart.IsAllSelected())
     {
         lPHours.Text = " все";
     }
     else
     {
         List <int> sel = HourStart.GetSelectedTitles();
         lPHours.Text = string.Empty;
         foreach (int i in sel)
         {
             if (string.IsNullOrEmpty(lPHours.Text))
             {
                 lPHours.Text += i.ToString();
             }
             else
             {
                 lPHours.Text += ", " + i.ToString();
             }
         }
     }
     if (MinuteStart.IsAllSelected())
     {
         lPMinutes.Text = " все";
     }
     else
     {
         List <int> sel = MinuteStart.GetSelectedTitles();
         lPMinutes.Text = string.Empty;
         foreach (int i in sel)
         {
             if (string.IsNullOrEmpty(lPMinutes.Text))
             {
                 lPMinutes.Text += i.ToString();
             }
             else
             {
                 lPMinutes.Text += ", " + i.ToString();
             }
         }
     }
     if (_role != "Worker")
     {
         lVypolnilDate.Text = " с " + CalendarFinish.SelectedDate.ToLongDateString() + " по " +
                              CalendarFinishEnd.SelectedDate.ToLongDateString();
     }
     else
     {
         lVypolnilDate.Text = " в любое время";
     }
     if (HourFinish.IsAllSelected())
     {
         lVHours.Text = " все";
     }
     else
     {
         List <int> sel = HourFinish.GetSelectedTitles();
         lVHours.Text = string.Empty;
         foreach (int i in sel)
         {
             if (string.IsNullOrEmpty(lVHours.Text))
             {
                 lVHours.Text += i.ToString();
             }
             else
             {
                 lVHours.Text += ", " + i.ToString();
             }
         }
     }
     if (MinuteFinish.IsAllSelected())
     {
         lVMinutes.Text = " все";
     }
     else
     {
         List <int> sel = MinuteFinish.GetSelectedTitles();
         lVMinutes.Text = string.Empty;
         foreach (int i in sel)
         {
             if (string.IsNullOrEmpty(lVMinutes.Text))
             {
                 lVMinutes.Text += i.ToString();
             }
             else
             {
                 lVMinutes.Text += ", " + i.ToString();
             }
         }
     }
     if (IsAllSelected(IdU))
     {
         lU.Text = " любой";
     }
     else
     {
         lU.Text = GetSelected(IdU);
     }
     if (IsAllSelected(IdM))
     {
         lM.Text = " любой";
     }
     else
     {
         lM.Text = GetSelected(IdM);
     }
     if (IsAllSelected(IdL))
     {
         lL.Text = " любой";
     }
     else
     {
         lL.Text = GetSelected(IdL);
     }
     if (IsAllSelected(Address))
     {
         if (GetSelectedTitles(IdU).Count == 1 && GetSelectedTitles(IdM).Count == 1)
         {
             KOS.App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
             List <string>     ls = db.GetAddress(GetSelectedTitles(IdU)[0], GetSelectedTitles(IdM)[0]);
             lAddress.Text = string.Empty;
             foreach (string s in ls)
             {
                 if (!string.IsNullOrEmpty(lAddress.Text))
                 {
                     lAddress.Text += ", ";
                 }
                 lAddress.Text += s;
             }
         }
         else
         {
             lAddress.Text = " любой";
         }
     }
     else
     {
         lAddress.Text = GetSelected(Address);
     }
     if (IsAllSelected(Category))
     {
         lCategory.Text = " любая";
     }
     else
     {
         lCategory.Text = GetSelected(Category);
     }
     if (IsAllSelected(From))
     {
         lSource.Text = " любой";
     }
     else
     {
         lSource.Text = GetSelected(From);
     }
     if (IsAllSelected(Prinyal))
     {
         lPrinyal.Text = " любой";
     }
     else
     {
         lPrinyal.Text = GetSelected(Prinyal);
     }
     if (_role == "Worker")
     {
         App_Code.Base          db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
         App_Code.Base.UserInfo ui = db.GetUserInfo(Page.User.Identity.Name);
         lWorker.Text = ui.Family + " " + ui.IO;
     }
     else if (IsAllSelected(Worker))
     {
         lWorker.Text = " любой";
     }
     else
     {
         lWorker.Text = GetSelected(Worker);
     }
 }
Exemplo n.º 25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckAccount();

            _from = DateTime.Now.AddDays(-2);
            //   Label1.Text = "С " + _from.ToString();
            //      if (!IsPostBack)
            //      CheckAccount();

            //       _from = DateTime.Now.AddDays(-2);
            //                   Label1.Text = "С " + _from.ToString();

            /*    CurDate.Text = DateTime.Now.Date.ToLongDateString();
             *    CurHour.Text = DateTime.Now.Hour.ToString();
             *    CurMinute.Text = DateTime.Now.Minute.ToString(); */

            if (!IsPostBack)
            {
                using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    conn.Open();

                    /*SqlCommand cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                     *  "join Users u on z.UserId=u.UserId " +
                     *  "where z.Category=N'застревание' and z.Start>@date and u.UserName=@user", conn);
                     * cmd.Parameters.AddWithValue("date", _from);
                     * cmd.Parameters.AddWithValue("user", User.Identity.Name);
                     * HyperLink1.Text = cmd.ExecuteScalar().ToString();
                     */
                    SqlCommand cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                                                    "join Users u on z.UserId=u.UserId " +
                                                    "where z.Category=N'застревание' and z.Finish is null and u.UserName=@user", conn);
                    cmd.Parameters.AddWithValue("user", User.Identity.Name);
                    Text2 = cmd.ExecuteScalar().ToString();
                    //   HyperLink2.Text = cmd.ExecuteScalar().ToString();
                    // плановые работы
                    cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                                         "join Users u on z.UserId=u.UserId " +
                                         "join UsersInRoles uir on uir.UserId=z.UserId " +
                                         "join Roles r on r.RoleId=uir.RoleId and r.RoleName='ODS' " +
                                         "where z.Category=N'плановые работы' and z.Finish is null and u.UserName=@user", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    cmd.Parameters.AddWithValue("user", User.Identity.Name);
                    Text3 = cmd.ExecuteScalar().ToString();
                    //   HyperLink3.Text = cmd.ExecuteScalar().ToString();
                    // внеплановые ремонты
                    cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                                         "join Users u on z.UserId=u.UserId " +
                                         "join UsersInRoles uir on uir.UserId=z.UserId " +
                                         "join Roles r on r.RoleId=uir.RoleId and r.RoleName='ODS' " +
                                         "where z.Category=N'внеплановые ремонты' and z.Finish is null and u.UserName=@user", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    cmd.Parameters.AddWithValue("user", User.Identity.Name);
                    Text8 = cmd.ExecuteScalar().ToString();
                    //   HyperLink8.Text = cmd.ExecuteScalar().ToString();

                    cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                                         "join Users u on z.UserId=u.UserId " +
                                         "where z.Category=N'останов' and z.Finish is null and u.UserName=@user", conn);
                    cmd.Parameters.AddWithValue("user", User.Identity.Name);
                    Text4 = cmd.ExecuteScalar().ToString();
                    //   HyperLink4.Text = cmd.ExecuteScalar().ToString();
                    //заявки от заказчика
                    cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                                         "join UsersInRoles uir on uir.UserId=z.UserId " +
                                         "join Roles r on r.RoleId=uir.RoleId and r.RoleName='ODS' " +
                                         "join Users u on z.UserId=u.UserId " +
                                         "where z.Finish is null and z.Category=N'заявка'and u.UserName=@user", conn);
                    cmd.Parameters.AddWithValue("user", User.Identity.Name);
                    //   HyperLink5.Text = cmd.ExecuteScalar().ToString();
                    //отправленные заявки
                    cmd = new SqlCommand("select  count(z.Id) from Zayavky z " +
                                         "join UserInfo ui on ui.UserId=z.UserId " +
                                         "join UsersInRoles uir on uir.UserId=z.UserId " +
                                         "join Roles r on r.RoleId=uir.RoleId and r.RoleName='ODS' " +
                                         "join Users u on z.UserId=u.UserId " +
                                         "where z.Category=N'заявка' and z.Start>@date and u.UserName=@user", conn);
                    cmd.Parameters.AddWithValue("date", _from);
                    cmd.Parameters.AddWithValue("user", User.Identity.Name);
                    //   HyperLink7.Text = cmd.ExecuteScalar().ToString();
                    cmd = new SqlCommand("select count(z.Id) from Zayavky z " +
                                         "join UsersInRoles uir on uir.UserId=z.UserId " +
                                         "join Roles r on r.RoleId=uir.RoleId and r.RoleName='ODS' " +
                                         "join Users u on z.UserId=u.UserId " +
                                         "where z.Category=N'заявка' and z.Finish is null and u.UserName=@user", conn);
                    cmd.Parameters.AddWithValue("user", User.Identity.Name);
                    Text6 = cmd.ExecuteScalar().ToString();
                    //   HyperLink6.Text = cmd.ExecuteScalar().ToString();
                    // подсчет активных событий
                    //   int all = int.Parse(HyperLink2.Text) + int.Parse(HyperLink3.Text) + int.Parse(HyperLink4.Text) + int.Parse(HyperLink6.Text)+ int.Parse(HyperLink8.Text);
                    int all = int.Parse(Text2) + int.Parse(Text3) + int.Parse(Text4) + int.Parse(Text6) + int.Parse(Text8);
                    HyperLink1.Text = all.ToString();
                    App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                    List <App_Code.Base.StoppedLift> list = db.GetStoppedODSLifts(User.Identity.Name);
                    int total = db.GetODSLifts(User.Identity.Name);
                    Worked.Text  = (total - list.Count).ToString();
                    Stopped.Text = list.Count.ToString();
                }
            }
        }
Exemplo n.º 26
0
        protected void Akt_Click(object sender, EventArgs e)
        {
            //блок формирования акта
            if (Label1.Text == "")
            {
                Msg.Text = "Для формирования актов требуется ПИН-код!"; return;
            }
            string PodpEmic = Spec + " " + WorkPin;

            using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("select t.Ttx from Ttx t " +
                                                "join LiftsTtx l on l.TtxId=t.Id " +
                                                //   "join Ttx tt on tt.Id=t.Id " +
                                                "where t.TtxTitleId=1 and l.LiftId=@t", conn);
                cmd.Parameters.AddWithValue("t", LiftId.SelectedValue);
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    adrs = dr[0].ToString();
                }
                dr.Close();
                cmd = new SqlCommand("select PlantNum from PhisicalAddr where LiftId=@lift", conn);
                cmd.Parameters.AddWithValue("lift", LiftId.Text);
                SqlDataReader dn = cmd.ExecuteReader();
                if (dn.Read())
                {
                    numlift = dn[0].ToString();
                }
                dn.Close();
                int    _wz = 0;
                string dat = DateTime.Now.Date.ToLongDateString();
                string dd  = DateTime.Now.Day.ToString();
                string mm  = DateTime.Now.Month.ToString();
                string yy  = DateTime.Now.Year.ToString();
                string hh  = DateTime.Now.Hour.ToString() + "час." + DateTime.Now.Minute.ToString() + "мин.";
                _wz = Int32.Parse(NumEvent.Text);
                App_Code.Base db       = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                DataTable     data     = db.GetEvent(_wz);
                string        worker   = data.Rows[0]["Family"].ToString() + " " + data.Rows[0]["IO"].ToString();
                BaseFont      baseFont = BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
                if (TypeAkt.SelectedValue == "Акт дефектовки")
                {
                    PdfReader  template = new PdfReader(@"C:\temp\aktDef.pdf"); // файл шаблона
                    PdfStamper stamper  = new PdfStamper(template, new FileStream(@"C:\temp\akt.pdf", FileMode.Create));
                    AcroFields fields   = stamper.AcroFields;
                    fields.AddSubstitutionFont(baseFont);
                    fields.SetField("NaktDef", NumEvent.Text + "-А1.1"); //номер акта
                    fields.SetField("adr", adrs);
                    fields.SetField("Nlift", LiftId.SelectedValue + " № " + numlift);
                    fields.SetField("opis1", Text.Text);
                    fields.SetField("lift", LiftId.SelectedValue);
                    fields.SetField("opis1", data.Rows[0]["EventId"].ToString());
                    fields.SetField("fill_6", Chel.SelectedValue);
                    fields.SetField("fill_7", Chas.SelectedValue);
                    fields.SetField("dateS", dd + "." + mm + "." + yy + "г.");
                    fields.SetField("dateP", dd + "." + mm + "." + yy + "г.");
                    fields.SetField("Podt", FamZak.Text);
                    fields.SetField("Sost", Label1.Text);
                    fields.SetField("name1", Name1.Text);
                    if (Name1.Text != "")
                    {
                        fields.SetField("npp1", " 1.");
                    }
                    fields.SetField("name2", Name2.Text);
                    if (Name2.Text != "")
                    {
                        fields.SetField("npp2", " 2.");
                    }
                    fields.SetField("name3", Name3.Text);
                    if (Name3.Text != "")
                    {
                        fields.SetField("npp3", " 3.");
                    }
                    fields.SetField("name4", Name4.Text);
                    if (Name4.Text != "")
                    {
                        fields.SetField("npp4", " 4.");
                    }
                    fields.SetField("name5", Name5.Text);
                    if (Name5.Text != "")
                    {
                        fields.SetField("npp5", " 5.");
                    }
                    fields.SetField("obz1", Obz1.Text);
                    fields.SetField("obz2", Obz2.Text);
                    fields.SetField("obz3", Obz3.Text);
                    fields.SetField("obz4", Obz4.Text);
                    fields.SetField("obz5", Obz5.Text);
                    fields.SetField("ID1", ID1.Text);
                    fields.SetField("ID2", ID2.Text);
                    fields.SetField("ID3", ID3.Text);
                    fields.SetField("ID4", ID4.Text);
                    fields.SetField("ID5", ID5.Text);
                    fields.SetField("kol1", Kol1.Text);
                    fields.SetField("kol2", Kol2.Text);
                    fields.SetField("kol3", Kol3.Text);
                    fields.SetField("kol4", Kol4.Text);
                    fields.SetField("kol5", Kol5.Text);
                    stamper.FormFlattening = false;// ложь - открыт для записи, истина - закрыт
                    stamper.Close();
                    // запись в БД
                    FileStream fs  = new FileStream(@"C:\temp\akt.pdf", FileMode.Open);
                    Byte[]     pdf = new byte[fs.Length];
                    fs.Read(pdf, 0, pdf.Length);
                    cmd = new SqlCommand("insert into Documents (Name, NumEvent, Image, NameFile, Status, Usr) values (@name, @nev, @img, @namefile, @st, @usr )", conn);
                    cmd.Parameters.AddWithValue("name", "акт дефектовки");
                    cmd.Parameters.AddWithValue("nev", NumEvent.Text);
                    cmd.Parameters.AddWithValue("usr", Label1.Text);
                    cmd.Parameters.Add("img", SqlDbType.Image).Value         = pdf;
                    cmd.Parameters.Add("namefile", SqlDbType.NVarChar).Value = NumEvent.Text + "-A1_1.pdf";
                    cmd.Parameters.AddWithValue("st", "не подписан заказчиком");
                    cmd.ExecuteNonQuery();
                    fs.Close();

                    /*     string commandText = @"C:\temp\akt.pdf";
                     *   var proc = new System.Diagnostics.Process();
                     *   proc.StartInfo.FileName = commandText;
                     *   proc.StartInfo.UseShellExecute = true;
                     *   proc.Start();
                     */
                    Response.ContentType = "image"; //image/Jpeg
                    Response.BinaryWrite(pdf);
                }
                else if (TypeAkt.SelectedValue == "Акт повреждения оборудования")
                {
                    PdfReader  template = new PdfReader(@"C:\temp\aktPovr.pdf"); // файл шаблона
                    PdfStamper stamper  = new PdfStamper(template, new FileStream(@"C:\temp\akt.pdf", FileMode.Create));
                    AcroFields fields   = stamper.AcroFields;
                    fields.AddSubstitutionFont(baseFont);
                    fields.SetField("NaktPovr", NumEvent.Text + "-А3.1"); //номер акта
                    fields.SetField("adr", adrs);
                    fields.SetField("Nlift", LiftId.SelectedValue + " № " + numlift);
                    fields.SetField("opis1", Text.Text);
                    fields.SetField("lift", LiftId.SelectedValue);
                    fields.SetField("opis1", data.Rows[0]["EventId"].ToString());
                    fields.SetField("fill_6", Chel.SelectedValue);
                    fields.SetField("fill_7", Chas.SelectedValue);
                    fields.SetField("dateS", dd + "." + mm + "." + yy + "г.");
                    fields.SetField("dateP", dd + "." + mm + "." + yy + "г.");
                    fields.SetField("Podt", FamZak.Text);
                    fields.SetField("Sost", Label1.Text);
                    fields.SetField("name1", Name1.Text);
                    if (Name1.Text != "")
                    {
                        fields.SetField("npp1", " 1.");
                    }
                    fields.SetField("name2", Name2.Text);
                    if (Name2.Text != "")
                    {
                        fields.SetField("npp2", " 2.");
                    }
                    fields.SetField("name3", Name3.Text);
                    if (Name3.Text != "")
                    {
                        fields.SetField("npp3", " 3.");
                    }
                    fields.SetField("name4", Name4.Text);
                    if (Name4.Text != "")
                    {
                        fields.SetField("npp4", " 4.");
                    }
                    fields.SetField("name5", Name5.Text);
                    if (Name5.Text != "")
                    {
                        fields.SetField("npp5", " 5.");
                    }
                    fields.SetField("obz1", Obz1.Text);
                    fields.SetField("obz2", Obz2.Text);
                    fields.SetField("obz3", Obz3.Text);
                    fields.SetField("obz4", Obz4.Text);
                    fields.SetField("obz5", Obz5.Text);
                    fields.SetField("ID1", ID1.Text);
                    fields.SetField("ID2", ID2.Text);
                    fields.SetField("ID3", ID3.Text);
                    fields.SetField("ID4", ID4.Text);
                    fields.SetField("ID5", ID5.Text);
                    fields.SetField("kol1", Kol1.Text);
                    fields.SetField("kol2", Kol2.Text);
                    fields.SetField("kol3", Kol3.Text);
                    fields.SetField("kol4", Kol4.Text);
                    fields.SetField("kol5", Kol5.Text);
                    stamper.FormFlattening = false;
                    stamper.Close();
                    // запись в БД
                    FileStream fs  = new FileStream(@"C:\temp\akt.pdf", FileMode.Open);
                    Byte[]     pdf = new byte[fs.Length];
                    fs.Read(pdf, 0, pdf.Length);
                    cmd = new SqlCommand("insert into Documents (Name, NumEvent, Image, NameFile, Status, Usr) values (@name, @nev, @img, @namefile, @st, @usr )", conn);
                    cmd.Parameters.AddWithValue("name", "акт повреждения оборудования");
                    cmd.Parameters.AddWithValue("nev", NumEvent.Text);
                    cmd.Parameters.AddWithValue("usr", Label1.Text);
                    cmd.Parameters.Add("img", SqlDbType.Image).Value         = pdf;
                    cmd.Parameters.Add("namefile", SqlDbType.NVarChar).Value = NumEvent.Text + "-A3_1.pdf";
                    cmd.Parameters.AddWithValue("st", "не подписан заказчиком");
                    cmd.ExecuteNonQuery();
                    fs.Close();

                    /*   string commandText = @"C:\temp\akt.pdf";
                     *  var proc = new System.Diagnostics.Process();
                     *  proc.StartInfo.FileName = commandText;
                     *  proc.StartInfo.UseShellExecute = true;
                     *  proc.Start();
                     */
                    Response.ContentType = "image"; //image/Jpeg
                    Response.BinaryWrite(pdf);
                }
            }
        }
Exemplo n.º 27
0
        protected void Email_Click(object sender, EventArgs e)
        {
            using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                conn.Open();
                string name = "", id = "", kol = "";
                string name1 = "", id1 = "", kol1 = "";
                string name2 = "", id2 = "", kol2 = "";
                string name3 = "", id3 = "", kol3 = "";
                string name4 = "", id4 = "", kol4 = "";
                string dat = DateTime.Now.Date.ToLongDateString();
                string dd  = DateTime.Now.Day.ToString();
                string mm  = DateTime.Now.Month.ToString();
                string yy  = DateTime.Now.Year.ToString();
                string hh  = DateTime.Now.Hour.ToString() + "час." + DateTime.Now.Minute.ToString() + "мин.";
                //   _wz = Int32.Parse(EventId.Text);
                App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                //   DataTable data = db.GetEvent(_wz);
                DataTable dt = db.GetPartsList(_wz);
                try
                {
                    name = dt.Rows[0]["Name"].ToString();
                    id   = dt.Rows[0]["NumID"].ToString();
                    kol  = dt.Rows[0]["Kol"].ToString();
                }
                catch { }
                try
                {
                    name1 = dt.Rows[1]["Name"].ToString();
                    id1   = dt.Rows[1]["NumID"].ToString();
                    kol1  = dt.Rows[1]["Kol"].ToString();
                }
                catch { }
                try
                {
                    name2 = dt.Rows[2]["Name"].ToString();
                    id2   = dt.Rows[2]["NumID"].ToString();
                    kol2  = dt.Rows[2]["Kol"].ToString();
                }
                catch { }
                try
                {
                    name3 = dt.Rows[3]["Name"].ToString();
                    id3   = dt.Rows[3]["NumID"].ToString();
                    kol3  = dt.Rows[3]["Kol"].ToString();
                }
                catch { }
                try
                {
                    name4 = dt.Rows[4]["Name"].ToString();
                    id4   = dt.Rows[4]["NumID"].ToString();
                    kol4  = dt.Rows[4]["Kol"].ToString();
                }

                catch { }

                BaseFont baseFont = BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

                PdfReader  template = new PdfReader(@"C:\temp\kp.pdf");    // файл шаблона
                PdfStamper stamper  = new PdfStamper(template, new FileStream(@"C:\temp\zkp.pdf", FileMode.Create));
                AcroFields fields   = stamper.AcroFields;
                fields.AddSubstitutionFont(baseFont);
                fields.SetField("dd", dd);
                fields.SetField("mm", mm);
                fields.SetField("yy", yy);
                if (name != "")
                {
                    fields.SetField("npp1", " 1.");
                }
                fields.SetField("name", name);
                if (name1 != "")
                {
                    fields.SetField("npp2", " 2.");
                }
                fields.SetField("name1", name1);
                if (name2 != "")
                {
                    fields.SetField("npp3", " 3.");
                }
                fields.SetField("name2", name2);
                if (name3 != "")
                {
                    fields.SetField("npp4", " 4.");
                }
                fields.SetField("name3", name3);
                if (name4 != "")
                {
                    fields.SetField("npp5", " 5.");
                }
                fields.SetField("name4", name4);
                fields.SetField("id", id);
                fields.SetField("id1", id1);
                fields.SetField("id2", id2);
                fields.SetField("id3", id3);
                fields.SetField("id4", id4);
                fields.SetField("kol", kol);
                fields.SetField("kol1", kol1);
                fields.SetField("kol2", kol2);
                fields.SetField("kol3", kol3);
                fields.SetField("kol4", kol4);
                // fields.SetField("kol1", kol1);
                fields.SetField("dni", "один");
                stamper.FormFlattening = false;    // ложь - открыт для записи, истина - закрыт
                stamper.Close();
                // запись в БД
                FileStream fs  = new FileStream(@"C:\temp\zkp.pdf", FileMode.Open);
                Byte[]     pdf = new byte[fs.Length];
                fs.Read(pdf, 0, pdf.Length);
                SqlCommand cmd = new SqlCommand("insert into Documents (Name, NumEvent, Image, NameFile, Status) values (@name, @nev, @img, @namefile, @st )", conn);
                cmd.Parameters.AddWithValue("name", "запрос КП");
                cmd.Parameters.AddWithValue("nev", Id.Text);
                cmd.Parameters.Add("img", SqlDbType.Image).Value         = pdf;
                cmd.Parameters.Add("namefile", SqlDbType.NVarChar).Value = Id.Text + "/ЗКП.pdf";
                cmd.Parameters.AddWithValue("st", "отправлен");
                cmd.ExecuteNonQuery();
                fs.Close();

                //  Response.ContentType = "image"; //image/Jpeg
                //  Response.BinaryWrite(pdf);
            }

            string text = "Здравствуйте! Вышлите пожалуйста коммерческое предложение на перечень запчастей во вложенном файле";

            if (!IsAllSelected(Post))
            {
                List <string> sel = GetSelectedEmails(Post);
                for (int i = 0; i < sel.Count; i++)
                {
                    Send(sel[i], text);
                }
            }
            Msg.Text = "Запрос нв КП разослан по выбранным адресам!";
        }
Exemplo n.º 28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckAccount();
            if (!string.IsNullOrEmpty(Request["lift"]))
            {
                _liftId = HttpUtility.HtmlDecode(Request["lift"]);
            }
            if (!string.IsNullOrEmpty(Request["ReturnUrl"]))
            {
                _url = HttpUtility.HtmlDecode(Request["ReturnUrl"]);
            }

            using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("select ui.Family, ui.IO from UserInfo ui " +
                                                "join Users u on u.UserId=ui.UserId where u.UserName=@userName", conn);
                cmd.Parameters.AddWithValue("userName", User.Identity.Name);
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    fam = dr[0].ToString();
                }
                io = dr[1].ToString();
                dr.Close();
            }

            App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            _workers = db.GetWorkers();
            if (!IsPostBack)
            {
                List <string> ls = db.GetIdU();
                IdU.DataSource = ls;
                IdU.DataBind();
                if (ls.Count > 0)
                {
                    IdU.SelectedIndex = 0;
                }
                IdU_SelectedIndexChanged(sender, e);

                string[] ss = { "1", "2" };
                Category.DataSource = ss;
                Category.DataBind();
                Category.SelectedIndex = 0;
                db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                List <string> types = db.GetWZTypes();
                Type.DataSource = types;
                Type.DataBind();
                Type.SelectedIndex = 0;
                PrimLift_TextChanged(this, EventArgs.Empty);
                LiftId_SelectedIndexChanged(this, EventArgs.Empty);

                To.DataSource = _workers;
                To.DataBind();
                To.SelectedIndex = 0;
            }
            List <string> typeakt = new List <string>()
            {
                "Акт дефектовки", "Акт повреждения оборудования"
            };
            List <string> chel = new List <string>()
            {
                "", "Да", "Нет"
            };
            List <string> chas = new List <string>()
            {
                "", "да", "Нет"
            };

            if (!IsPostBack)
            {
                TypeAkt.DataSource = typeakt;
                TypeAkt.DataBind();
                TypeAkt.SelectedIndex = 0;

                Chel.DataSource = chel;
                Chel.DataBind();
                Chel.SelectedIndex = 0;

                Chas.DataSource = chas;
                Chas.DataBind();
                Chas.SelectedIndex = 0;
            }
        }
Exemplo n.º 29
0
 protected void Page_Load(object sender, EventArgs e)
 {
     App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
     _IdU = db.GetIdU();
 }
Exemplo n.º 30
0
        protected void Parts_Click(object sender, EventArgs e)
        {
            using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("insert into PartsList (NumEvent, Foto, namefoto, Name, NumID, Kol, Obz) values (@nev, @foto, @namefoto, @name, @numid, @kol, @obz) ", conn);
                //выбор фото из устройства
                string namePhoto = FileUpload.FileName;
                //преобразование в двоичный код
                byte[] photo = FileUpload.FileBytes;
                cmd.Parameters.AddWithValue("nev", NumEvent.Text);
                cmd.Parameters.Add("foto", SqlDbType.Image).Value        = photo;
                cmd.Parameters.Add("namefoto", SqlDbType.NVarChar).Value = namePhoto;
                cmd.Parameters.AddWithValue("name", Text1.Text);
                cmd.Parameters.AddWithValue("obz", TextBox1.Text);
                cmd.Parameters.AddWithValue("numid", Text2.Text);
                cmd.Parameters.AddWithValue("kol", Text3.Text);
                cmd.ExecuteNonQuery();
                int           ei = int.Parse(NumEvent.Text);
                App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                DataTable     dt = db.GetPartsList(ei);
                try
                {
                    Name1.Text = dt.Rows[0]["Name"] is DBNull ? "" : dt.Rows[0]["Name"].ToString();
                    Obz1.Text  = dt.Rows[0]["Obz"] is DBNull ? "" : dt.Rows[0]["Obz"].ToString();
                    ID1.Text   = dt.Rows[0]["NumID"] is DBNull ? "" : dt.Rows[0]["NumID"].ToString();
                    Kol1.Text  = dt.Rows[0]["Kol"] is DBNull ? "" : dt.Rows[0]["Kol"].ToString();
                }

                catch { }
                try
                {
                    Name2.Text = dt.Rows[1]["Name"] is DBNull ? "" : dt.Rows[1]["Name"].ToString();
                    Obz2.Text  = dt.Rows[1]["Obz"] is DBNull ? "" : dt.Rows[1]["Obz"].ToString();
                    ID2.Text   = dt.Rows[1]["NumID"] is DBNull ? "" : dt.Rows[1]["NumID"].ToString();
                    Kol2.Text  = dt.Rows[1]["Kol"] is DBNull ? "" : dt.Rows[1]["Kol"].ToString();
                }
                catch { }
                try
                {
                    Name3.Text = dt.Rows[2]["Name"] is DBNull ? "" : dt.Rows[2]["Name"].ToString();
                    Obz3.Text  = dt.Rows[2]["Obz"] is DBNull ? "" : dt.Rows[2]["Obz"].ToString();
                    ID3.Text   = dt.Rows[2]["NumID"] is DBNull ? "" : dt.Rows[2]["NumID"].ToString();
                    Kol3.Text  = dt.Rows[2]["Kol"] is DBNull ? "" : dt.Rows[2]["Kol"].ToString();
                }
                catch { }
                try
                {
                    Name4.Text = dt.Rows[3]["Name"] is DBNull ? "" : dt.Rows[3]["Name"].ToString();
                    Obz4.Text  = dt.Rows[3]["Obz"] is DBNull ? "" : dt.Rows[3]["Obz"].ToString();
                    ID4.Text   = dt.Rows[3]["NumID"] is DBNull ? "" : dt.Rows[3]["NumID"].ToString();
                    Kol4.Text  = dt.Rows[3]["Kol"] is DBNull ? "" : dt.Rows[3]["Kol"].ToString();
                }
                catch { }
                try
                {
                    Name5.Text = dt.Rows[4]["Name"].ToString();
                    Obz5.Text  = dt.Rows[4]["Obz"].ToString();
                    ID5.Text   = dt.Rows[4]["NumID"].ToString();
                    Kol5.Text  = dt.Rows[4]["Kol"].ToString();
                }
                catch { }
            }
            Text1.Text = ""; Text2.Text = ""; Text3.Text = ""; TextBox1.Text = "";
        }