コード例 #1
0
ファイル: status.aspx.cs プロジェクト: davkhun/projects
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(TextBox1.Text))
            {
                M1.SetMessage = "Поле должно быть заполнено!";
                MessageExtender.Show();
                return;
            }

            if (Button1.Text.Equals("Добавить"))
            {
                MSQLData.InsertCommand = "INSERT IGNORE INTO status (value) VALUES (@status)";
                MSQLData.InsertParameters.Add("@status", TextBox1.Text.Trim());
                MSQLData.Insert();
            }
            else if (Button1.Text.Equals("Изменить"))
            {
                MSQLData.UpdateCommand = "UPDATE IGNORE status SET value=@status WHERE id=@id";
                MSQLData.UpdateParameters.Add("@status", TextBox1.Text.Trim());
                MSQLData.UpdateParameters.Add("@id", GridView1.SelectedDataKey.Value.ToString());
                MSQLData.Update();
                Button1.Text            = "Добавить";
                GridView1.SelectedIndex = -1;
            }
            TextBox1.Text = string.Empty;
        }
コード例 #2
0
ファイル: models.aspx.cs プロジェクト: davkhun/projects
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(TextBox1.Text))
            {
                M1.SetMessage = "Поле название быть заполнено!";
                MessageExtender.Show();
                return;
            }

            if (Button1.Text.Equals("Добавить"))
            {
                MSQLData.InsertCommand = "INSERT IGNORE INTO models (type_id,name) VALUES (@tid,@name)";
                MSQLData.InsertParameters.Add("@name", TextBox1.Text.Trim());
                MSQLData.InsertParameters.Add("@tid", DropDownList1.SelectedValue);
                MSQLData.Insert();
            }
            else if (Button1.Text.Equals("Изменить"))
            {
                MSQLData.UpdateCommand = "UPDATE IGNORE models SET type_id=@tid,name=@name WHERE id=@id";
                MSQLData.UpdateParameters.Add("@name", TextBox1.Text.Trim());
                MSQLData.UpdateParameters.Add("@tid", DropDownList1.SelectedValue);
                MSQLData.UpdateParameters.Add("@id", GridView1.SelectedDataKey.Value.ToString());
                MSQLData.Update();
                Button1.Text            = "Добавить";
                GridView1.SelectedIndex = -1;
            }
            TextBox1.Text = string.Empty;
        }
コード例 #3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(TextBox1.Text))
            {
                M1.SetMessage = "Поле код быть заполнено!";
                MessageExtender.Show();
                return;
            }

            if (Button1.Text.Equals("Добавить"))
            {
                MSQLData.InsertCommand = "INSERT IGNORE INTO divisions (code,description) VALUES (@code,@descr)";
                MSQLData.InsertParameters.Add("@code", TextBox1.Text.Trim());
                MSQLData.InsertParameters.Add("@descr", TextBox2.Text.Trim());
                MSQLData.Insert();
            }
            else if (Button1.Text.Equals("Изменить"))
            {
                MSQLData.UpdateCommand = "UPDATE IGNORE divisions SET code=@code,description=@descr WHERE id=@id";
                MSQLData.UpdateParameters.Add("@code", TextBox1.Text.Trim());
                MSQLData.UpdateParameters.Add("@descr", TextBox2.Text.Trim());
                MSQLData.UpdateParameters.Add("@id", GridView1.SelectedDataKey.Value.ToString());
                MSQLData.Update();
                Button1.Text            = "Добавить";
                GridView1.SelectedIndex = -1;
            }
            TextBox1.Text = string.Empty;
            TextBox2.Text = string.Empty;
        }
コード例 #4
0
ファイル: default.aspx.cs プロジェクト: davkhun/projects
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            List <ADuser> usr = new List <ADuser>();

            if (e.NewValues["manager"] != null)
            {
                usr = new ADconnector().GetUser(e.NewValues["manager"].ToString());
            }

            MSQLData.UpdateCommand = "UPDATE ue SET is_inv=@is_inv,manager=@manager,manager_uname=@muname,status_id=@sid,office=@office,comment=@comment,update_date=now(),uname=@uname,manager_placement=@mp WHERE id=@id";
            MSQLData.UpdateParameters.Add("@is_inv", e.NewValues["is_inv"].ToString().ToLower() == "false" ? "0" : "1");
            MSQLData.UpdateParameters.Add("@manager", e.NewValues["manager"]?.ToString());
            MSQLData.UpdateParameters.Add("@muname", usr.Count == 0 ? null : usr[0].samAccountName);
            MSQLData.UpdateParameters.Add("@mp", usr.Count == 0 ? null : usr[0].placement);
            MSQLData.UpdateParameters.Add("@sid", ((DropDownList)(GridView1.Rows[e.RowIndex].FindControl("statusDdl"))).SelectedValue);
            MSQLData.UpdateParameters.Add("@office", usr.Count == 0 ? null : usr[0].office);
            MSQLData.UpdateParameters.Add("@comment", e.NewValues["comment"]?.ToString());
            MSQLData.UpdateParameters.Add("@uname", user.uname);
            MSQLData.UpdateParameters.Add("@id", GridView1.DataKeys[e.RowIndex].Value.ToString());
            MSQLData.Update();

            // пишем изменение статуса
            Label l = GridView1.Rows[e.RowIndex].FindControl("statusL") as Label;

            if (l.Text != ((DropDownList)(GridView1.Rows[e.RowIndex].FindControl("statusDdl"))).SelectedItem.Text)
            {
                MSQLData.InsertCommand = "INSERT INTO status_history (date,old_status,new_status,uname) VALUES (now(),@os,@ns,@uname)";
                MSQLData.InsertParameters.Add("@os", l.Text);
                MSQLData.InsertParameters.Add("@ns", ((DropDownList)(GridView1.Rows[e.RowIndex].FindControl("statusDdl"))).SelectedItem.Text);
                MSQLData.InsertParameters.Add("@uname", user.uname);
                MSQLData.Insert();
            }
        }
コード例 #5
0
ファイル: supdocs.aspx.cs プロジェクト: davkhun/projects
 protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     MSQLData.UpdateCommand = "UPDATE supdocs SET date=@dt,price=@price WHERE id=@id";
     MSQLData.UpdateParameters.Add("@dt", string.IsNullOrEmpty(e.NewValues["date"].ToString()) ? null : Convert.ToDateTime(e.NewValues["date"]).ToString("yyyy-MM-dd"));
     MSQLData.UpdateParameters.Add("@price", e.NewValues["price"]?.ToString().Replace(" ", "").Replace("_", "").Replace(",", "."));
     MSQLData.UpdateParameters.Add("@id", GridView1.DataKeys[e.RowIndex].Value.ToString());
     MSQLData.Update();
 }
コード例 #6
0
ファイル: supdocs.aspx.cs プロジェクト: davkhun/projects
 private void Q1_btnHandler(string value)
 {
     if (value.Contains("SupDocDelete"))
     {
         MSQLData.UpdateCommand = "UPDATE supdocs SET active=0 WHERE id=@id";
         MSQLData.UpdateParameters.Add("@id", value.Split('|')[1]);
         MSQLData.Update();
     }
 }
コード例 #7
0
ファイル: suppliers.aspx.cs プロジェクト: davkhun/projects
 protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     MSQLData.UpdateCommand = "UPDATE suppliers SET short_name=@sname,inn=@inn,address=@address,site=@site,manager=@manager,phone=@phone,email=@email WHERE id=@id";
     MSQLData.UpdateParameters.Add("@inn", e.NewValues["inn"]?.ToString());
     MSQLData.UpdateParameters.Add("@address", e.NewValues["address"]?.ToString());
     MSQLData.UpdateParameters.Add("@site", e.NewValues["site"]?.ToString());
     MSQLData.UpdateParameters.Add("@manager", e.NewValues["manager"]?.ToString());
     MSQLData.UpdateParameters.Add("@phone", e.NewValues["phone"]?.ToString());
     MSQLData.UpdateParameters.Add("@email", e.NewValues["email"]?.ToString());
     MSQLData.UpdateParameters.Add("@sname", e.NewValues["short_name"]?.ToString());
     MSQLData.UpdateParameters.Add("@id", GridView1.DataKeys[e.RowIndex].Value.ToString());
     MSQLData.Update();
 }
コード例 #8
0
ファイル: supdocs.aspx.cs プロジェクト: davkhun/projects
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "downloadSup")
            {
                int           rowInd   = Convert.ToInt32(e.CommandArgument);
                string        jsonpath = (GridView1.Rows[rowInd].FindControl("downloadPath") as Label).Text;
                List <string> path     = JsonConvert.DeserializeObject <List <string> >(jsonpath);
                if (path.Count == 1)
                {
                    FileInfo fi           = new FileInfo(path[0]);
                    string   downloadName = (GridView1.Rows[rowInd].FindControl("nameL") as Label).Text + "_" + (GridView1.Rows[rowInd].FindControl("docnumL") as Label).Text + fi.Extension;
                    Response.Clear();
                    Response.AddHeader("Content-Disposition", $"attachment;filename=\"{downloadName}\"");
                    Response.Cache.SetCacheability(HttpCacheability.NoCache);
                    HttpContext.Current.Response.Charset         = "utf-8";
                    HttpContext.Current.Response.ContentEncoding = Encoding.GetEncoding("windows-1251");
                    Response.TransmitFile(Server.MapPath("~/upload/" + path[0]));
                }
                else // если файлов много - пакуем и отдаем архив
                {
                    foreach (string fname in Directory.GetFiles(Server.MapPath("~") + @"upload\tmp\"))
                    {
                        File.Delete(fname);
                    }
                    string packageName = "docs_" + DateTime.Now.ToShortDateString() + ".zip";
                    foreach (string one in path)
                    {
                        File.Copy(Server.MapPath("~") + @"upload\" + one, Server.MapPath("~") + @"upload\tmp\" + one);
                    }
                    using (ZipFile z = new ZipFile())
                    {
                        z.AlternateEncodingUsage = ZipOption.Always;
                        z.AlternateEncoding      = Encoding.UTF8;
                        foreach (string fname in Directory.GetFiles(Server.MapPath("~") + @"upload\tmp\"))
                        {
                            z.AddFile(fname, "");
                        }
                        z.Save(Server.MapPath("~") + @"upload\tmp\" + packageName);
                    }
                    Response.Clear();
                    Response.AddHeader("Content-Disposition", $"attachment;filename=\"{HttpUtility.UrlEncode(packageName, Encoding.UTF8).Replace('+', '_')}\"");
                    Response.Cache.SetCacheability(HttpCacheability.NoCache);
                    Response.TransmitFile(Server.MapPath("~/upload/tmp/" + packageName));
                }

                Response.End();
            }
            if (e.CommandName == "ShowSup")
            {
                int        rowInd = Convert.ToInt32(e.CommandArgument);
                LinkButton lb     = GridView1.Rows[rowInd].FindControl("showL") as LinkButton;

                Image img = GridView1.Rows[rowInd].FindControl("Image1") as Image;
                if (lb.Text == "Показать")
                {
                    string        path     = (GridView1.Rows[rowInd].FindControl("downloadPath") as Label).Text;
                    List <string> jsonPath = JsonConvert.DeserializeObject <List <string> >(path);
                    img.ImageUrl = "/upload/" + jsonPath[0];
                    lb.Text      = "Скрыть";
                    return;
                }
                if (lb.Text == "Скрыть")
                {
                    img.ImageUrl = null;
                    lb.Text      = "Показать";
                }
            }
            if (e.CommandName == "uploadSup")
            {
                int                rowInd   = Convert.ToInt32(e.CommandArgument);
                FileUpload         fu       = GridView1.Rows[rowInd].FindControl("uploadDocFU") as FileUpload;
                List <string>      fileList = new List <string>();
                HttpFileCollection hfc      = Request.Files;
                foreach (string file in hfc.Keys)
                {
                    HttpPostedFile hpf = hfc[file];
                    FileInfo       fi  = new FileInfo(hpf.FileName);
                    string         fn  = fi.Name + "_" + DateTime.Now.Ticks + fi.Extension;
                    fileList.Add(fn);
                    string saveLocation = Server.MapPath("~/upload/") + fn;
                    fu.PostedFile.SaveAs(saveLocation);
                }


                MSQLData.UpdateCommand = "UPDATE supdocs SET scan_path=@sp WHERE id=@id";
                MSQLData.UpdateParameters.Add("@sp", JsonConvert.SerializeObject(fileList));
                MSQLData.UpdateParameters.Add("@id", GridView1.DataKeys[rowInd].Value.ToString());
                MSQLData.Update();
            }
        }