示例#1
0
 protected void Save_Click(object sender, EventArgs e)
 {
     using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
     {
         conn.Open();
         SqlCommand cmd = new SqlCommand("delete from WorkerLifts " +
                                         "where UserId=@userId and LiftId in " +
                                         "(select LiftId from Lifts where IdU=@idU and IdM=@idM)", conn);
         Base.PersonData pd = _workers.Find(delegate(Base.PersonData i)
         {
             return(i.Title == Worker.SelectedValue);
         });
         cmd.Parameters.AddWithValue("userId", pd.Id);
         cmd.Parameters.AddWithValue("idU", IdU.SelectedValue);
         cmd.Parameters.AddWithValue("idM", IdM.SelectedValue);
         cmd.ExecuteNonQuery();
         List <string> liftIds = GetSelectedTitles(IdL);
         foreach (string liftId in liftIds)
         {
             cmd = new SqlCommand("insert into WorkerLifts (UserId, LiftId) values (@userId, @liftId)", conn);
             cmd.Parameters.AddWithValue("userId", pd.Id);
             cmd.Parameters.AddWithValue("liftId", liftId);
             cmd.ExecuteNonQuery();
         }
     }
 }
示例#2
0
        protected void DaysHollidayPeriodSet_Click(object sender, EventArgs e)
        {
            DaysHollidayPeriodSetting.Visible = false;

            Base.PersonData pd = _workers.Find(delegate(Base.PersonData i)
            {
                return(i.Title == WorkerName.SelectedValue);
            });
            List <App_Code.Base.CheckedLift> list = new List <Base.CheckedLift>();

            App_Code.Base   db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            List <DateTime> d  = db.GetDaysHolliday(pd.Id, DHStart.SelectedDate, DHEnd.SelectedDate);

            for (DateTime date = DHStart.SelectedDate; date <= DHEnd.SelectedDate; date = date.AddDays(1))
            {
                App_Code.Base.CheckedLift cl = new Base.CheckedLift()
                {
                    Title = date.ToShortDateString()
                };
                if (d.FindIndex(delegate(DateTime i)
                {
                    return(i == date);
                }) >= 0)
                {
                    cl.Checked = true;
                }
                list.Add(cl);
            }
            DaysHolliday.DataSource = list;
            DaysHolliday.DataBind();
            SetDaysHolliday.Visible = true;
        }
示例#3
0
 protected void Save_Click(object sender, EventArgs e)
 {
     using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
     {
         conn.Open();
         SqlCommand cmd = new SqlCommand("insert into ZPrim (LiftId, [Date], WhoWrote, Responce, Category, [To]) " +
                                         "values (@liftId, @d, (select UserId from Users where UserName=@userName), @r, @c, @t)", conn);
         cmd.Parameters.AddWithValue("liftId", LiftId.SelectedValue);
         cmd.Parameters.AddWithValue("d", DateTime.Now);
         cmd.Parameters.AddWithValue("userName", User.Identity.Name);
         cmd.Parameters.AddWithValue("r", Responсe.Text);
         cmd.Parameters.AddWithValue("c", int.Parse(Category.SelectedValue));
         Base.PersonData pd = _workers.Find(delegate(Base.PersonData i)
         {
             return(i.Title == To.SelectedValue);
         });
         cmd.Parameters.AddWithValue("t", pd.Id);
         cmd.ExecuteNonQuery();
         Msg.Text = "Замечание добавлено";
         if (!string.IsNullOrEmpty(_url))
         {
             Response.Redirect(_url);
         }
     }
 }
示例#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();
            _hollidaysType = db.GetWorkTypes();
            if (!IsPostBack)
            {
                SaveOrClear.DataSource = _soc;
                SaveOrClear.DataBind();
                SaveOrClear.SelectedIndex = 0;
                HollidaysType.DataSource  = _hollidaysType;
                HollidaysType.DataBind();
                HollidaysType.SelectedIndex = 0;
                Base.UserInfo ui = db.GetUserInfo(_workers[0].UserName);
                From.Text  = ui.HourBeg.ToString();
                To.Text    = ui.HourEnd.ToString();
                Lunch.Text = ui.Lunch.ToString();
                DataTable   data = db.GetWorkTime();
                List <Data> ls   = new List <Data>();
                foreach (DataRow dr in data.Rows)
                {
                    ls.Add(new Data()
                    {
                        Name  = dr["Family"].ToString() + " " + dr["IO"].ToString(),
                        From  = dr["HourBeg"].ToString(),
                        To    = dr["HourEnd"].ToString(),
                        Lunch = dr["Lunch"].ToString()
                    });
                }
                Graf.DataSource = ls;
                Graf.DataBind();

                WorkerName.DataSource = _workers;
                WorkerName.DataBind();
                WorkerName.SelectedIndex = 0;
                List <string> s = db.GetIdU();
                IdU.DataSource = s;
                IdU.DataBind();
                if (s.Count > 0)
                {
                    IdU.SelectedIndex = 0;
                }
                IdU_SelectedIndexChanged(sender, e);
                //Beg.SelectedDate = DateTime.Now.Date;
                //End.SelectedDate = DateTime.Now.Date.AddMonths(1);
                Calendar1.SelectedDate = DateTime.Now.Date;
                Calendar2.SelectedDate = DateTime.Now.Date.AddMonths(1);
                Calendar3.SelectedDate = DateTime.Now.Date;
                DHStart.SelectedDate   = DateTime.Now.Date;
                DHEnd.SelectedDate     = DateTime.Now.Date.AddMonths(1);
                Base.PersonData pd     = _workers.Find(delegate(Base.PersonData i)
                {
                    return(i.Title == WorkerName.SelectedValue);
                });
                List <Base.UserLift> ul = db.GetUserLift(pd.Id);
                AllList.DataSource = ul;
                AllList.DataBind();
            }
        }
示例#5
0
        protected void IdM_SelectedIndexChanged(object sender, EventArgs e)
        {
            App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            Base.PersonData pd = _workers.Find(delegate(Base.PersonData i)
            {
                return(i.Title == Worker.SelectedValue);
            });
            List <Base.UserLift> data = db.GetUserLift(pd.UserName, IdU.SelectedValue, IdM.SelectedValue);

            IdL.DataSource = data;
            IdL.DataBind();
        }
示例#6
0
        protected void Worker_SelectedIndexChanged(object sender, EventArgs e)
        {
            IdM_SelectedIndexChanged(sender, e);

            Base.PersonData pd = _workers.Find(delegate(Base.PersonData i)
            {
                return(i.Title == WorkerName.SelectedValue);
            });
            App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
            Base.UserInfo ui = db.GetUserInfo(pd.UserName);
            From.Text  = ui.HourBeg.ToString();
            To.Text    = ui.HourEnd.ToString();
            Lunch.Text = ui.Lunch.ToString();
        }
示例#7
0
 protected void HollidayPeriodSave_Click(object sender, EventArgs e)
 {
     Base.PersonData pd = _workers.Find(delegate(Base.PersonData i)
     {
         return(i.Title == WorkerName.SelectedValue);
     });
     if (pd == null)
     {
         Msg.Text = "Ошибка сохранения";
         return;
     }
     Base.HoolidaysType bw = _hollidaysType.Find(delegate(Base.HoolidaysType i)
     {
         return(i.Title == HollidaysType.SelectedValue);
     });
     if (bw == null || bw.Id < 1)
     {
         Msg.Text = "Ошибка сохранения";
         return;
     }
     using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
     {
         conn.Open();
         SqlCommand cmd = new SqlCommand("delete from Holidays where " +
                                         "UserId=@userId and [Date] between @d1 and @d2", conn);
         cmd.Parameters.AddWithValue("userId", pd.Id);
         cmd.Parameters.AddWithValue("d1", HollidayStart.SelectedDate);
         cmd.Parameters.AddWithValue("d2", HollidayEnd.SelectedDate.AddDays(1).AddSeconds(-1));
         cmd.ExecuteNonQuery();
         for (DateTime date = HollidayStart.SelectedDate; date < HollidayEnd.SelectedDate.AddDays(1);
              date = date.AddDays(1))
         {
             cmd = new SqlCommand("insert into Holidays " +
                                  "(UserId, [Date], HollidaysTypeId) " +
                                  "values (@userId, @date, @type)", conn);
             cmd.Parameters.AddWithValue("userId", pd.Id);
             cmd.Parameters.AddWithValue("date", date);
             cmd.Parameters.AddWithValue("type", bw.Id);
             cmd.ExecuteNonQuery();
             Msg.Text = string.Empty;
         }
     }
 }
示例#8
0
        protected void SaveDaysHolliday_Click(object sender, EventArgs e)
        {
            List <string> list = GetSelectedTitles(DaysHolliday);
            DateTime      date = DHStart.SelectedDate;

            Base.PersonData pd = _workers.Find(delegate(Base.PersonData i)
            {
                return(i.Title == WorkerName.SelectedValue);
            });
            using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                conn.Open();
                foreach (string i in list)
                {
                    DateTime h = DateTime.Parse(i);
                    for (; date <= h; date = date.AddDays(1))
                    {
                        SqlCommand cmd = new SqlCommand("delete from Holidays where UserId=@id and [Date]=@d", conn);
                        cmd.Parameters.AddWithValue("id", pd.Id);
                        cmd.Parameters.AddWithValue("d", date);
                        cmd.ExecuteNonQuery();
                    }
                    SqlCommand cmd2 = new SqlCommand("insert into Holidays " +
                                                     "([Date], UserId, HollidaysTypeId) values (@d, @id, 9)", conn);
                    cmd2.Parameters.AddWithValue("id", pd.Id);
                    cmd2.Parameters.AddWithValue("d", h);
                    cmd2.ExecuteNonQuery();
                }
                for (; date <= DHEnd.SelectedDate; date = date.AddDays(1))
                {
                    SqlCommand cmd = new SqlCommand("delete from Holidays where UserId=@id and [Date]=@d", conn);
                    cmd.Parameters.AddWithValue("id", pd.Id);
                    cmd.Parameters.AddWithValue("d", date);
                    cmd.ExecuteNonQuery();
                }
            }
            DaysHollidayPeriodSetting.Visible = true;
            SetDaysHolliday.Visible           = false;
        }
示例#9
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            //TheWorks.SetPeriod(Beg.SelectedDate, End.SelectedDate);

            Base.PersonData pd = _workers.Find(delegate(Base.PersonData i)
            {
                return(i.Title == WorkerName.SelectedValue);
            });
            MonthPlan1.SetMonth(new DateTime(DateTime.Now.Year, 1, 1), pd.UserName);
            MonthPlan2.SetMonth(new DateTime(DateTime.Now.Year, 2, 1), pd.UserName);
            MonthPlan3.SetMonth(new DateTime(DateTime.Now.Year, 3, 1), pd.UserName);
            MonthPlan4.SetMonth(new DateTime(DateTime.Now.Year, 4, 1), pd.UserName);
            MonthPlan5.SetMonth(new DateTime(DateTime.Now.Year, 5, 1), pd.UserName);
            MonthPlan6.SetMonth(new DateTime(DateTime.Now.Year, 6, 1), pd.UserName);
            MonthPlan7.SetMonth(new DateTime(DateTime.Now.Year, 7, 1), pd.UserName);
            MonthPlan8.SetMonth(new DateTime(DateTime.Now.Year, 8, 1), pd.UserName);
            MonthPlan9.SetMonth(new DateTime(DateTime.Now.Year, 9, 1), pd.UserName);
            MonthPlan10.SetMonth(new DateTime(DateTime.Now.Year, 10, 1), pd.UserName);
            MonthPlan11.SetMonth(new DateTime(DateTime.Now.Year, 11, 1), pd.UserName);
            MonthPlan12.SetMonth(new DateTime(DateTime.Now.Year, 12, 1), pd.UserName);
        }
示例#10
0
        protected void Save_Click(object sender, EventArgs e)
        {
            int from, to, lunch;

            if (!int.TryParse(From.Text, out from))
            {
                Msg.Text = "Укажите начало рабочего дня";
                return;
            }
            if (!int.TryParse(To.Text, out to))
            {
                Msg.Text = "Укажите конец рабочего дня";
                return;
            }
            if (!int.TryParse(Lunch.Text, out lunch))
            {
                Msg.Text = "Укажите перерыв на обед";
                return;
            }
            Base.PersonData pd = _workers.Find(delegate(Base.PersonData i)
            {
                return(i.Title == WorkerName.SelectedValue);
            });
            using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("update UserInfo " +
                                                "set HourBeg=@t1, HourEnd=@t2, Lunch=@t3 " +
                                                "where UserId=@userId", conn);
                cmd.Parameters.AddWithValue("userId", pd.Id);
                cmd.Parameters.AddWithValue("t1", from);
                cmd.Parameters.AddWithValue("t2", to);
                cmd.Parameters.AddWithValue("t3", lunch);
                cmd.ExecuteNonQuery();
                Msg.Text = string.Empty;
            }
        }
示例#11
0
 protected void Clear_Click(object sender, EventArgs e)
 {
     Base.PersonData pd = _workers.Find(delegate(Base.PersonData i)
     {
         return(i.Title == WorkerName.SelectedValue);
     });
     if (pd == null)
     {
         Msg.Text = "Ошибка сохранения";
         return;
     }
     using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
     {
         conn.Open();
         SqlCommand cmd = new SqlCommand("delete from Holidays " +
                                         "where UserId=@userId and " +
                                         "[Date] between @d1 and @d2", conn);
         cmd.Parameters.AddWithValue("userId", pd.Id);
         cmd.Parameters.AddWithValue("d1", ClearStart.SelectedDate);
         cmd.Parameters.AddWithValue("d2", ClearEnd.SelectedDate);
         cmd.ExecuteNonQuery();
         Msg.Text = string.Empty;
     }
 }
示例#12
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);
        }
示例#13
0
        protected void Save_Click(object sender, EventArgs e)
        {
            /*   if (LiftId.SelectedIndex == 0)
             * {
             *     Msg.Text = "Внимание! Вы забыли выбрать номер лифта.";
             *     return;
             * }*/
            // добавлено поле для фото и его имени файла
            using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("insert into WorkerZayavky " +
                                                "(UserId, [Date], [Text], LiftId, [Type], [Foto], nameFoto, [Name], [NumID], [Kol]) " +
                                                "values ((select UserId from Users where UserName=@user), @date, @text, @lift, @type, @foto, @namefoto, @name, @numid, @kol)", conn);
                cmd.Parameters.AddWithValue("user", User.Identity.Name);
                cmd.Parameters.AddWithValue("text", Text.Text);
                cmd.Parameters.AddWithValue("name", Text1.Text);
                cmd.Parameters.AddWithValue("numid", Text2.Text);
                cmd.Parameters.AddWithValue("kol", Text3.Text);
                DateTime date; date = DateTime.Now;
                cmd.Parameters.AddWithValue("date", date);
                cmd.Parameters.AddWithValue("lift", string.IsNullOrEmpty(LiftId.SelectedValue) ? null : LiftId.SelectedValue);
                cmd.Parameters.AddWithValue("type", Type.SelectedValue);
                //выбор фото из устройства
                string namePhoto = FileUpload.FileName;
                //преобразование в двоичный код
                byte[] photo = FileUpload.FileBytes;
                //Запись фото и его имени файла в БД
                cmd.Parameters.Add("foto", SqlDbType.Image).Value        = photo;
                cmd.Parameters.Add("namefoto", SqlDbType.NVarChar).Value = namePhoto;
                cmd.ExecuteNonQuery();
                //выбор номера
                cmd = new SqlCommand("select wz.Id from WorkerZayavky wz " +
                                     "join Users u on wz.UserId=u.UserId " +
                                     "where u.UserName=@user and wz.LiftId=@liftId and [Date]=@s", conn);
                cmd.Parameters.AddWithValue("liftId", LiftId.SelectedValue);
                cmd.Parameters.AddWithValue("user", User.Identity.Name);
                cmd.Parameters.AddWithValue("s", date);
                int id = int.Parse(cmd.ExecuteScalar().ToString());
                nzay = Convert.ToString(id);//номер заявки
                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();
                cmd = new SqlCommand("select LiftId, IdU, IdM from Lifts " +
                                     "where LiftId=@lift", conn);
                cmd.Parameters.AddWithValue("lift", LiftId.SelectedValue);
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    u = dr[1].ToString(); m = dr[2].ToString();
                }
                dr.Close();
                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);
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    adrs = dr[0].ToString();
                }
                dr.Close();
                //запись события в БД
                cmd = new SqlCommand("insert into Events" +
                                     "(EventId, RegistrId, DataId, WZayavId, Sourse, Family, IO, TypeId, IdU, IdM, LiftId, Foto, namefoto, Name, NumID, Kol, Address, Obz ) " +
                                     "values (@text, @reg, @s, @id, @f, @fam, @io, @c, @u, @m, @liftid, @foto, @namefoto, @name, @numid, @kol, @adr, @obz )", conn);
                cmd.Parameters.AddWithValue("text", Text.Text);
                cmd.Parameters.AddWithValue("reg", "Эксплуатация лифтов");
                cmd.Parameters.AddWithValue("s", date);
                cmd.Parameters.AddWithValue("id", id);
                cmd.Parameters.AddWithValue("f", "Эмика Техник");
                cmd.Parameters.AddWithValue("fam", fam);
                cmd.Parameters.AddWithValue("io", io);
                cmd.Parameters.AddWithValue("c", Type.SelectedValue);
                cmd.Parameters.AddWithValue("u", u);
                cmd.Parameters.AddWithValue("m", m);
                cmd.Parameters.AddWithValue("liftId", LiftId.SelectedValue);
                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.Parameters.AddWithValue("adr", adrs);
                cmd.ExecuteNonQuery();
                // получаем номер события
                cmd = new SqlCommand("select Id from Events where DataId=@s and WZayavId=@id", conn);
                cmd.Parameters.AddWithValue("s", date);
                cmd.Parameters.AddWithValue("id", id);
                evid = int.Parse(cmd.ExecuteScalar().ToString());
                dr   = cmd.ExecuteReader();
                if (dr.Read())
                {
                    Msg.Text      = "Заявка зарегистрирована! При необходимости, добавьте дополнительные запчасти в список. ";
                    NumEvent.Text = dr[0].ToString();
                }
                dr.Close();
                Parts_Click(sender, e);
            }

            if (Type.Text == "замечания по лифтам")
            {
                using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("insert into ZPrim (LiftId, [Date], WhoWrote, Responce, Category, [To], WzId) " +
                                                    "values (@liftId, @d, (select UserId from Users where UserName=@userName), @r, @c, @t, @id)", conn);
                    cmd.Parameters.AddWithValue("liftId", LiftId.SelectedValue);
                    cmd.Parameters.AddWithValue("d", DateTime.Now);
                    cmd.Parameters.AddWithValue("userName", User.Identity.Name);
                    cmd.Parameters.AddWithValue("r", Text.Text);
                    cmd.Parameters.AddWithValue("id", nzay);
                    cmd.Parameters.AddWithValue("c", int.Parse(Category.SelectedValue));
                    Base.PersonData pd = _workers.Find(delegate(Base.PersonData i)
                    {
                        return(i.Title == To.SelectedValue);
                    });
                    cmd.Parameters.AddWithValue("t", pd.Id);
                    cmd.ExecuteNonQuery();
                    Msg.Text = "Заявка зарегистрирована! Замечание добавлено в базу!";
                    if (!string.IsNullOrEmpty(_url))
                    {
                        Response.Redirect(_url);
                    }
                }
            }
            Text1.Text = ""; TextBox1.Text = ""; Text2.Text = ""; Text3.Text = "";
        }
示例#14
0
        protected void SaveWeekEnd_Click(object sender, EventArgs e)
        {
            Base.PersonData pd = _workers.Find(delegate(Base.PersonData i)
            {
                return(i.Title == WorkerName.SelectedValue);
            });
            if (pd == null)
            {
                Msg.Text = "Ошибка сохранения";
                return;
            }
            using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                conn.Open();
                for (DateTime date = WeekEndStart.SelectedDate; date < WeekEndEnd.SelectedDate.AddDays(1);
                     date = date.AddDays(1))
                {
                    switch (date.DayOfWeek)
                    {
                    case DayOfWeek.Monday: if (!HollidayDaysOfWeek.Items[0].Selected)
                        {
                            continue;
                        }
                        break;

                    case DayOfWeek.Tuesday: if (!HollidayDaysOfWeek.Items[1].Selected)
                        {
                            continue;
                        }
                        break;

                    case DayOfWeek.Wednesday: if (!HollidayDaysOfWeek.Items[2].Selected)
                        {
                            continue;
                        }
                        break;

                    case DayOfWeek.Thursday: if (!HollidayDaysOfWeek.Items[3].Selected)
                        {
                            continue;
                        }
                        break;

                    case DayOfWeek.Friday: if (!HollidayDaysOfWeek.Items[4].Selected)
                        {
                            continue;
                        }
                        break;

                    case DayOfWeek.Saturday: if (!HollidayDaysOfWeek.Items[5].Selected)
                        {
                            continue;
                        }
                        break;

                    case DayOfWeek.Sunday: if (!HollidayDaysOfWeek.Items[6].Selected)
                        {
                            continue;
                        }
                        break;
                    }
                    SetHolliday(date, pd.Id);
                    Msg.Text = string.Empty;
                }
            }
        }
示例#15
0
        protected void H2_Click(object sender, EventArgs e)
        {
            Base.PersonData pd = _workers.Find(delegate(Base.PersonData i)
            {
                return(i.Title == WorkerName.SelectedValue);
            });
            if (pd == null)
            {
                Msg.Text = "Ошибка сохранения";
                return;
            }
            Base.HoolidaysType type = _hollidaysType.Find(delegate(Base.HoolidaysType ht)
            {
                return(HollidaysType.SelectedValue == ht.Title);
            });
            if (type == null)
            {
                Msg.Text = "Ошибка сохранения";
                return;
            }
            if (Calendar3.SelectedDate < Calendar1.SelectedDate || Calendar3.SelectedDate > Calendar2.SelectedDate)
            {
                Msg.Text = "Ошибка сохранения";
                return;
            }
            using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                conn.Open();
                switch (type.Id)
                {
                case 5:     // сутки через трое
                    for (DateTime date = Calendar3.SelectedDate.AddDays(1); date < Calendar2.SelectedDate.AddDays(1); date = date.AddDays(1))
                    {
                        for (int i = 0; date < Calendar2.SelectedDate.AddDays(1) && i < 3; date = date.AddDays(1))
                        {
                            SetHolliday(date, pd.Id);
                            ++i;
                        }
                    }
                    break;

                case 6:     // два через два
                    for (DateTime date = Calendar3.SelectedDate; date < Calendar2.SelectedDate.AddDays(1); date = date.AddDays(3))
                    {
                        SetHolliday(date, pd.Id);
                        date = date.AddDays(1);
                        if (date > Calendar2.SelectedDate)
                        {
                            break;
                        }
                        SetHolliday(date, pd.Id);
                    }
                    break;

                case 7:     // неделя через неделю
                    for (DateTime date = Calendar3.SelectedDate; date < Calendar2.SelectedDate.AddDays(1); date = date.AddDays(7))
                    {
                        for (int i = 0; date < Calendar2.SelectedDate.AddDays(1) && i < 7; date = date.AddDays(1))
                        {
                            SetHolliday(date, pd.Id);
                            ++i;
                        }
                    }
                    break;

                case 8:     // две недели через две недели
                    for (DateTime date = Calendar3.SelectedDate; date < Calendar2.SelectedDate.AddDays(1); date = date.AddDays(14))
                    {
                        for (int i = 0; date < Calendar2.SelectedDate.AddDays(1) && i < 14; date = date.AddDays(1))
                        {
                            SetHolliday(date, pd.Id);
                            ++i;
                        }
                    }
                    break;
                }
                Msg.Text = string.Empty;
            }
        }