protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "reup") { int xy = Convert.ToInt32(e.CommandArgument); Model.Position pos = new DAL.PositionDAO().getPositionByNum(GridView1.Rows[xy].Cells[1].Text); add.Visible = false; search.Visible = false; Button btn = sender as Button; GridViewRow row = GridView1.Rows[xy]; SysUser s = new DAL.SysUserDAO().getUserByNum(row.Cells[2].Text); } else if (e.CommandName == "deletee") { int x = Convert.ToInt32(e.CommandArgument); string dataid = GridView1.Rows[x].Cells[1].Text; string dataname = GridView1.Rows[x].Cells[2].Text; bool yy = new DAL.DataCopyDAO().deleteCopyById(dataid); if (yy) { ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除成功!');", true); try { File.Delete(@"~/DataPackage/" + dataname + ".mdf"); } catch { ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除失败,未找到文件!');", true); } dc = new Warehouse.Controllor.DataRecovery_Controllor().getDataCopy(); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除失败!');", true); } } refresh(); }
protected void Button4_Click(object sender, EventArgs e) //入库确定添加按钮点击事件 { cleaTitle(); Button b = sender as Button; if (TextBox1.Text.Trim() == "" || TextBox2.Text.Trim() == "" || TextBox3.Text.Trim() == "" || TextBox4.Text.Trim() == "" || TextBox5.Text.Trim() == "" || TextBox6.Text.Trim() == "") { Response.Write("<script>alert('所有信息不能为空!')</script>"); } else { bool condition = true; //记录输入的东西是否符合条件,全都正确为true Position p = new DAL.PositionDAO().getPositionByNum(TextBox1.Text.Trim()); if (p == null) { condition = false; Label2.Text = "没有查询到此库位"; } Goods g = new DAL.GoodsDAO().getGoodsByNum(TextBox2.Text.Trim()); if (g == null) { condition = false; Label4.Text = "没有查询到此物品"; } int inamount; try { inamount = int.Parse(TextBox3.Text.Trim()); if (inamount <= 0) { int.Parse("测试"); } } catch { condition = false; inamount = 0; Label6.Text = "输入格式错误,请输入大于0的整数"; } Provider pr = new DAL.ProviderDAO().getProviderByNum(TextBox4.Text.Trim()); if (pr == null) { condition = false; Label8.Text = "没有查询到此供应商"; } if (TextBox5.Text.Length >= 100) { condition = false; Label10.Text = "输入长度大于100"; } DateTime dt; try { dt = DateTime.Parse(TextBox6.Text.Trim()); if (b.Text != "确认修改") { if (dt < DateTime.Now) { condition = false; Label12.Text = "输入日期必须大于等于今天的日期"; } } } catch { condition = false; dt = DateTime.Parse("2018-8-8"); Label12.Text = "输入日期的格式不正确"; } if (condition) { if (b.Text != "确认修改") { Batch bt = new Batch(); bt.BatchNum = new Warehouse.Tools.batchNum().protect_batchNumByWPB("供货"); bt.ProorrecNum = TextBox4.Text.Trim(); bt.Condition = "准备"; bt.OutorinType = "入库"; bool batchsucc = new DAL.BatchDao().addBatch(bt); new Warehouse.Tools.AddSysLog().addlog("1", "批次", "添加"); Inin ii = new Inin(); ii.PositionNum = TextBox1.Text.Trim(); ii.GoodsNum = TextBox2.Text.Trim(); ii.InAmount = inamount; ii.Remark = TextBox5.Text.Trim(); ii.Date = dt; bool ininsucc = new DAL.IninDAO().addIn(ii); if (batchsucc && ininsucc) { ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('添加成功!');", true); new Warehouse.Tools.AddSysLog().addlog("1", "未完成入库", "添加"); addIn.Visible = false; refreAllIn(); clea(); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('添加失败!');", true); } } else { Inin ii = new Inin(); ii.PositionNum = TextBox1.Text.Trim(); ii.GoodsNum = TextBox2.Text.Trim(); ii.InAmount = inamount; ii.Remark = TextBox5.Text.Trim(); ii.Date = dt; ii.InID = inID; ii.BatchNum = inBatch; ii.UserId = "1"; bool ininsucc = new DAL.IninDAO().updateIn(ii); if (ininsucc) { ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('修改成功!');", true); new Warehouse.Tools.AddSysLog().addlog("1", "未完成入库", "修改"); addIn.Visible = false; GridView2.Visible = true; refreAllIn(); inID = null; inBatch = null; clea(); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('修改失败!');", true); } } } else { } } }