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; }
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; }
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; }
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(); } }
protected void Button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(shortNameT.Text)) { M1.SetMessage = "Краткое наименование должно быть заполнено!"; MessageExtender.Show(); return; } if (string.IsNullOrEmpty(nameT.Text)) { M1.SetMessage = "Наименование должно быть заполнено!"; MessageExtender.Show(); return; } MSQLData.InsertCommand = "INSERT IGNORE INTO suppliers (name,short_name,inn,address,site,manager,phone,email) VALUES (@name,@short_name,@inn,@address,@site,@manager,@phone,@email)"; MSQLData.InsertParameters.Add("@name", nameT.Text); MSQLData.InsertParameters.Add("@short_name", shortNameT.Text); MSQLData.InsertParameters.Add("@inn", innT.Text); MSQLData.InsertParameters.Add("@address", addressT.Text); MSQLData.InsertParameters.Add("@site", siteT.Text); MSQLData.InsertParameters.Add("@manager", managerT.Text); MSQLData.InsertParameters.Add("@phone", phoneT.Text.Replace("\n", "<br/>")); MSQLData.InsertParameters.Add("@email", emailT.Text); MSQLData.Insert(); nameT.Text = string.Empty; innT.Text = string.Empty; addressT.Text = string.Empty; siteT.Text = string.Empty; managerT.Text = string.Empty; phoneT.Text = string.Empty; emailT.Text = string.Empty; shortNameT.Text = string.Empty; newRecDiv.Visible = false; }
protected void Button1_Click(object sender, EventArgs e) { if (!FileUpload1.HasFile) { M1.SetMessage = "Не выбран скан накладной!"; MessageExtender.Show(); return; } if (string.IsNullOrEmpty(doc_numberT.Text)) { M1.SetMessage = "Не указан номер накладной!"; MessageExtender.Show(); return; } 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; FileUpload1.PostedFile.SaveAs(saveLocation); } MSQLData.InsertCommand = "INSERT IGNORE INTO supdocs (supplier_id,doc_number,date,price,scan_path,uname,date_insert) VALUES (@sid,@docnum,@date,@price,@scan_path,@uname,now())"; MSQLData.InsertParameters.Add("@sid", supDdl.SelectedValue); MSQLData.InsertParameters.Add("@docnum", doc_numberT.Text); MSQLData.InsertParameters.Add("@date", string.IsNullOrEmpty(dateT.Text) ? null : Convert.ToDateTime(dateT.Text).ToString("yyyy-MM-dd")); MSQLData.InsertParameters.Add("@price", priceT.Text.Replace(" ", "").Replace("_", "").Replace(",", ".")); MSQLData.InsertParameters.Add("@scan_path", JsonConvert.SerializeObject(fileList)); MSQLData.InsertParameters.Add("@uname", user.uname); MSQLData.Insert(); doc_numberT.Text = string.Empty; dateT.Text = string.Empty; priceT.Text = string.Empty; newRecDiv.Visible = false; }