Пример #1
0
 string BuildWorkerWhere(string w)
 {
     if (w != null && _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);
         PersonData awd = workerData.Find(delegate(PersonData wd)
         {
             return(wd.Title == ui.Family + " " + ui.IO);
         });
         if (awd == null)
         {
             return(null);
         }
         if (string.IsNullOrEmpty(w))
         {
             w = "where ";
         }
         else
         {
             w += "and ";
         }
         w += "(z.Worker is null or z.Worker='" + awd.Id + "') ";
     }
     else if (w != null && (!IsAllSelected(Worker) || workerData.Count == 1))
     {
         List <string> u  = GetSelectedTitles(Worker);
         string        tu = string.Empty;
         foreach (string i in u)
         {
             PersonData awd = workerData.Find(delegate(PersonData wd)
             {
                 return(wd.Title == i);
             });
             if (awd != null)
             {
                 tu += (string.IsNullOrEmpty(tu) ? "" : ",") + "'" + awd.Id + "'";
             }
         }
         if (!string.IsNullOrEmpty(tu))
         {
             if (string.IsNullOrEmpty(w))
             {
                 w = "where ";
             }
             else
             {
                 w += "and ";
             }
             w += "(z.Worker is null or z.Worker in (" + tu + ")) ";
         }
         else
         {
             return(null);
         }
     }
     return(w);
 }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
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);
     }
 }
Пример #5
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];
         }
     }
 }
Пример #6
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);
        }