private void Datagrid2_UpdateCommand(object source, DataGridCommandEventArgs e) { if (((TextBox)e.Item.Cells[6].Controls[0]).Text.Trim() == "" || !this.JudgeIsNum(((TextBox)e.Item.Cells[6].Controls[0]).Text.Trim())) { this.Popup("单价必须是数字!"); this.hidecontrol(e.Item.ItemIndex); return; } if (((TextBox)e.Item.Cells[11].Controls[1]).Text.Trim() == "" || !this.JudgeIsNum(((TextBox)e.Item.Cells[11].Controls[1]).Text.Trim())) { this.Popup("入库数量必须是数字!"); this.hidecontrol(e.Item.ItemIndex); return; } if (((TextBox)e.Item.Cells[14].Controls[1]).Text.Trim() == "" || !this.JudgeIsNum(((TextBox)e.Item.Cells[14].Controls[1]).Text.Trim())) { this.Popup("其它费用数量必须是数字!"); this.hidecontrol(e.Item.ItemIndex); return; } if (((System.Web.UI.HtmlControls.HtmlInputText)e.Item.Cells[16].Controls[1]).Value == "") { this.Popup("生产日期不能为空!"); this.hidecontrol(e.Item.ItemIndex); return; } if (((System.Web.UI.HtmlControls.HtmlInputText)e.Item.Cells[18].Controls[1]).Value == "") { this.Popup("过期日期不能为空!"); this.hidecontrol(e.Item.ItemIndex); return; } string strExpire = Helper.Query("select cnnExpire from tbInventory where cnvcInvCode='" + e.Item.Cells[4].Text.Trim() + "'").Rows[0]["cnnExpire"].ToString(); if (strExpire != "" && strExpire != "0") { DateTime dtExpdate = DateTime.Parse(((System.Web.UI.HtmlControls.HtmlInputText)e.Item.Cells[18].Controls[1]).Value); TimeSpan ts = dtExpdate.Subtract(DateTime.Now.Date); if (ts.Days <= int.Parse(strExpire)) { this.Popup("到期天数不足" + strExpire + "天,不能入库!"); this.hidecontrol(e.Item.ItemIndex); return; } } Entity.RdRecordDetail rrd = new RdRecordDetail(); rrd.cnnAutoID = int.Parse(e.Item.Cells[0].Text.Trim()); rrd.cnnPrice = Math.Round(decimal.Parse(((TextBox)e.Item.Cells[6].Controls[0]).Text.Trim()), 2); rrd.cnnQuantity = Math.Round(decimal.Parse(((TextBox)e.Item.Cells[11].Controls[1]).Text.Trim()), 2); rrd.cnnExtraCost = Math.Round(decimal.Parse(((TextBox)e.Item.Cells[14].Controls[1]).Text.Trim()), 2); rrd.cndMdate = DateTime.Parse(((System.Web.UI.HtmlControls.HtmlInputText)e.Item.Cells[16].Controls[1]).Value.Trim()); rrd.cndExpDate = DateTime.Parse(((System.Web.UI.HtmlControls.HtmlInputText)e.Item.Cells[18].Controls[1]).Value.Trim()); rrd.cnvcCommens = ((TextBox)e.Item.Cells[19].Controls[0]).Text.Trim(); if (rrd.cnnAutoID.ToString() == "" || rrd.cnnAutoID == 0) { this.Popup("采购入库单子表标识不正确!"); this.hidecontrol(e.Item.ItemIndex); return; } if (rrd.cndMdate.CompareTo(rrd.cndExpDate) >= 0) { this.Popup("生产日期大于过期日期,不正确!"); this.hidecontrol(e.Item.ItemIndex); return; } // DateTime dttmp=rrd.cndMdate; // switch(rrd.cnvcMassUnit) // { // case "1": // if(dttmp.AddDays(rrd.cnnMassDate).CompareTo(rrd.cndExpDate)!=0) // { // this.Popup("生产日期+保质期数后不等于过期日期,请检查!"); // this.hidecontrol(e.Item.ItemIndex); // return; // } // break; // case "2": // if(dttmp.AddMonths(rrd.cnnMassDate).CompareTo(rrd.cndExpDate)!=0) // { // this.Popup("生产日期+保质期数后不等于过期日期,请检查!"); // this.hidecontrol(e.Item.ItemIndex); // return; // } // break; // case "3": // if(dttmp.AddYears(rrd.cnnMassDate).CompareTo(rrd.cndExpDate)!=0) // { // this.Popup("生产日期+保质期数后不等于过期日期,请检查!"); // this.hidecontrol(e.Item.ItemIndex); // return; // } // break; // } Entity.OperLog ol = new AMSApp.zhenghua.Entity.OperLog(); ol.cnvcOperType = "修改采购入库子表"; ol.cnvcOperID = this.oper.strLoginID; ol.cnvcDeptID = this.oper.strDeptID; StorageFacade sto = new StorageFacade(); int ret = sto.UpdatePoStockEnterDetail(ol, rrd); if (ret > 0) { this.Popup("修改采购入库单子表明细成功!"); } else { this.Popup("修改采购入库单子表明细失败!"); } this.DBBind(); }
private void Button1_Click(object sender, System.EventArgs e) { //添加计量单位组 if (this.JudgeIsNull(this.TextBox2.Text)) { this.Popup("计量单位组编码获取失败,请关闭页面重新获取"); return; } if (this.JudgeIsNull(this.TextBox1.Text)) { this.Popup("请输入计量单位组名称"); return; } if (this.JudgeIsNull(this.TextBox3.Text)) { this.Popup("计量单位编码获取失败,请关闭页面重新获取"); return; } if (this.JudgeIsNull(this.TextBox4.Text)) { this.Popup("请输入计量单位名称"); return; } if (this.JudgeIsNull(this.TextBox6.Text)) { this.Popup("请输入换算率"); return; } if (!this.JudgeIsNum(this.TextBox6.Text)) { this.Popup("换算率必须是数字"); return; } if (this.lblTitle.Text == "添加计量单位") { Entity.OperLog ol = new AMSApp.zhenghua.Entity.OperLog(); ol.cnvcOperType = "添加计量单位"; ol.cnvcOperID = this.oper.strLoginID; ol.cnvcDeptID = this.oper.strDeptID; Entity.ComputationUnit cu = new AMSApp.zhenghua.Entity.ComputationUnit(); cu.cnbMainUnit = this.CheckBox1.Checked; cu.cniChangRate = float.Parse(this.TextBox6.Text); cu.cnvcComunitCode = this.TextBox3.Text; cu.cnvcComUnitName = this.TextBox4.Text; cu.cnvcGroupCode = this.TextBox2.Text; Business.ComputationUnit bcu = new AMSApp.zhenghua.Business.ComputationUnit(); int ret = bcu.AddComputationUnit(ol, cu); if (ret > 0) { this.Popup("添加计量单位成功!"); } else { this.Popup("添加计量单位失败!"); } //this.Response.Write("<script type=\"text/javascript\">window.returnValue=true;window.close()</script>"); } else if (this.lblTitle.Text == "修改计量单位") { Entity.OperLog ol = new AMSApp.zhenghua.Entity.OperLog(); ol.cnvcOperType = "修改计量单位"; ol.cnvcOperID = this.oper.strLoginID; ol.cnvcDeptID = this.oper.strDeptID; Entity.ComputationUnit cu = new AMSApp.zhenghua.Entity.ComputationUnit(); cu.cnbMainUnit = this.CheckBox1.Checked; cu.cniChangRate = float.Parse(this.TextBox6.Text); cu.cnvcComunitCode = this.TextBox3.Text; cu.cnvcComUnitName = this.TextBox4.Text; cu.cnvcGroupCode = this.TextBox2.Text; Business.ComputationUnit bcu = new AMSApp.zhenghua.Business.ComputationUnit(); int ret = bcu.UpdateComputationUnit(ol, cu); if (ret > 0) { this.Popup("修改计量单位成功!"); } else { this.Popup("修改计量单位失败!"); } } this.Response.Write("<script type=\"text/javascript\">window.returnValue=true;window.close()</script>"); }