protected void fvProject_ItemInserting(object sender, FormViewInsertEventArgs e) { //TODO: Set value of Project Account and CreateBy field e.Values["Account"] = SEOMembershipManager.GetUser(User.Identity.Name).Account; e.Values["CreateBy"] = User.Identity.Name; }
protected void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e) { BillingEntities db=new BillingEntities(); User user = db.Users.FirstOrDefault(s => s.Login == User.Identity.Name); e.Values.Add("UserFromId", user.Id); e.Values.Add("UserToId", int.Parse(Request.Params["Id"])); e.Values.Add("IsReaded", false); }
protected void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e) { e.Values["Incidente"] = getNewIncidente().ToString(); e.Values["Usuario"] = BitOP.Global.Usuario; e.Values["Planta"] = SelPlanta.Text; e.Values["Area"] = SelArea.Text; e.Values["Proceso"] = SelProceso.Text; }
protected void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e) { int tariffId = int.Parse(((DropDownList)FormView1.FindControl("TariffIdDropDownList")).SelectedValue); e.Values.Add("TariffId", tariffId); TextBox balanceTextBox = ((TextBox)FormView1.FindControl("BalanceTextBox")); if (balanceTextBox.Text == "") e.Values["Balance"] = (decimal?)0; }
protected void frmCampoPlantilla_ItemInserting(object sender, FormViewInsertEventArgs e) { if (e.Values["CMP_LONGITUD_CABECERA"].ToString() == string.Empty) { e.Values["CMP_LONGITUD_CABECERA"] = null; } if (e.Values["CMP_POSICION_RELATIVA"].ToString() == string.Empty) { e.Values["CMP_POSICION_RELATIVA"] = null; } }
protected void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e) { FileUpload fileUpload = FormView1.FindControl("fileUpload") as FileUpload; e.Values.Add("FileVersion", Path.GetFileNameWithoutExtension(fileUpload.FileName)); e.Values.Add("FileName", Path.GetFileName(fileUpload.FileName)); e.Values.Add("FileBytes", fileUpload.FileBytes); e.Values.Add("PostTime", DateTime.Now); string savingType = drpSavingType2.SelectedValue; e.Values.Add("SavingType", savingType); }
/** * We are in "insert" mode, and the "insert" button was pressed * */ protected void PGFV_ItemInserting(Object sender, FormViewInsertEventArgs e) { String albumName = ((TextBox)this.PGFV.FindControl("albumNameTextBox")).Text; String albumDescription = ((TextBox)this.PGFV.FindControl("albumDescTextBox")).Text; //Create new entry controller.createNewAlbum(albumName, albumDescription); rebind(); //rebind the grid //now, find the id to select it on the Grid this.PGFV.ChangeMode(FormViewMode.ReadOnly); rebindForm(-1); }
//******添加数据使用的函数和方法****** /// <summary> /// 添加一条生产记录或者报废记录数据到数据库 /// </summary> /// <param name="cmd">查询对象</param> /// <param name="lotId">lot卡号</param> /// <param name="e">包含有数据列表值的事件参数</param> /// <param name="isToNextDept">是否转入下部门结存</param> /// <returns></returns> internal static bool InsertOneRecord( SqlCommand cmd, string lotId, FormViewInsertEventArgs e, bool isToNextDept = true ) { //当前部门 string deptName = HttpContext.Current.Session["dept_name"].ToString(); //调用另一重载函数 return InsertOneRecord(cmd, lotId, e, string.Empty, deptName, isToNextDept); }
//******添加数据使用的函数和方法****** /// <summary> /// 添加一条生产记录或者报废记录数据到数据库 /// </summary> /// <param name="cmd">查询对象</param> /// <param name="lotId">批量卡序号</param> /// <param name="e">包含有数据列表值的事件参数</param> /// <param name="isToNextProc">是否转入下部门结存</param> /// <param name="isAccept">是否已经确认过该卡数量</param> /// <returns></returns> internal static bool InsertOneRecord( SqlCommand cmd, string lotId, FormViewInsertEventArgs e, bool isToNextProc = true, bool? isAccept = true ) { //当前部门 string procName = HttpContext.Current.Session["proc_name"].ToString(); //调用另一重载函数 return InsertOneRecord(cmd, lotId, e, procName, isToNextProc, isAccept); }
/** * Currently NOT used * We are in "insert" mode, and the "insert" button was pressed * */ protected void PrideRunOrdersEditorFormView_ItemInserting(Object sender, FormViewInsertEventArgs e) { String firstName = ((TextBox)PrideRunOrdersEditorFormView.FindControl("firstNameTextBox")).Text; String lastName = ((TextBox)PrideRunOrdersEditorFormView.FindControl("lastNameTextBox")).Text; String email = ((TextBox)PrideRunOrdersEditorFormView.FindControl("emailTextBox")).Text; //Response.Write("Inserting...<br>"); //Response.Write(eventName + "," + distance + "," + city + "," + state + "," + website + "," + cal.ToShortDateString()); controller.insertAMember(firstName, lastName, email); rebind(); //rebind the grid PrideRunOrdersEditorFormView.ChangeMode(FormViewMode.ReadOnly); rebindForm(-1); }
protected void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e) { DropDownList UsuarioSel = (DropDownList)FormView1.FindControl("DropDownListUsuario"); DropDownList AreaSel = (DropDownList)FormView1.FindControl("DropDownListArea"); DropDownList ProcesoSel = (DropDownList)FormView1.FindControl("DropDownListProceso"); DropDownList EquipoSel = (DropDownList)FormView1.FindControl("DropDownListEquipo"); DropDownList TurnoSel = (DropDownList)FormView1.FindControl("DropDownListTurno"); DropDownList DiasPermSel = (DropDownList)FormView1.FindControl("DropDownListDiasPerm"); e.Values["Usuario"] = UsuarioSel.SelectedValue.ToString(); e.Values["Area"] = AreaSel.SelectedValue.ToString(); e.Values["Proceso"] = ProcesoSel.SelectedValue.ToString(); e.Values["Equipo"] = EquipoSel.SelectedValue.ToString(); e.Values["Turno"] = TurnoSel.SelectedValue.ToString(); e.Values["DiasAtrasoReg"] = Convert.ToInt16(DiasPermSel.SelectedValue.ToString()); }
protected void frmProtocolo_ItemInserting(object sender, FormViewInsertEventArgs e) { if (e.Values["PTR_PUERTO"].ToString() == string.Empty) { e.Values["PTR_PUERTO"] = null; } if (e.Values["PTR_TIMEOUT_REQUEST"].ToString() == string.Empty) { e.Values["PTR_TIMEOUT_REQUEST"] = null; } if (e.Values["PTR_TIMEOUT_RESPONSE"].ToString() == string.Empty) { e.Values["PTR_TIMEOUT_RESPONSE"] = null; } if (e.Values["PTR_FRAME"].ToString() == string.Empty) { e.Values["PTR_FRAME"] = null; } }
/** * We are in "insert" mode, and the "insert" button was pressed * */ protected void EventEditorFormView_ItemInserting(Object sender, FormViewInsertEventArgs e) { String eventName = ((TextBox)EventEditorFormView.FindControl("eventNameTextBox")).Text; eventName = eventName.Replace("'", "''"); String distance = ((TextBox)EventEditorFormView.FindControl("distanceTextBox")).Text; String city = ((TextBox)EventEditorFormView.FindControl("cityTextBox")).Text; String state = ((TextBox)EventEditorFormView.FindControl("stateTextBox")).Text; String website = ((TextBox)EventEditorFormView.FindControl("websiteTextBox")).Text; //DateTime cal = (DateTime)((CalendarExtender)EventEditorFormView.FindControl("calendartest")).SelectedDate; String date = ((TextBox)EventEditorFormView.FindControl("eventDateTextBox")).Text; String[] splitDate = date.Split('/'); DateTime cal = new DateTime(Int32.Parse(splitDate[2]), Int32.Parse(splitDate[0]), Int32.Parse(splitDate[1])); //Response.Write("Inserting...<br>"); //Response.Write(eventName + "," + distance + "," + city + "," + state + "," + website + "," + cal.ToShortDateString()); controller.createNewEvent(cal, eventName, distance, city, state, website); rebind(); //rebind the grid //now, find the id to select it on the Grid EventEditorFormView.ChangeMode(FormViewMode.ReadOnly); rebindForm(-1); //Response.Write("Inserting"); }
protected void formFeeds_ItemInserting(object sender, FormViewInsertEventArgs e) { XmlDocument xdoc = XmlDataSource_feed.GetXmlDocument(); XmlElement feeds = xdoc.SelectSingleNode("feeds") as XmlElement; XmlElement feed = xdoc.CreateElement("feed"); XmlAttribute name = xdoc.CreateAttribute("name"); XmlAttribute url = xdoc.CreateAttribute("url"); name.InnerText = ((TextBox)formFeeds.Row.Cells[0].FindControl("nameInsert")).Text; url.InnerText = ((TextBox)formFeeds.Row.Cells[0].FindControl("urlInsert")).Text; feeds.AppendChild(feed); feed.Attributes.Append(name); feed.Attributes.Append(url); XmlDataSource_feed.Save(); XmlDataSource_feed.DataBind(); formFeeds.DataBind(); formFeeds.ChangeMode(FormViewMode.ReadOnly); e.Cancel = true; }
public void DoOnItemInserting (FormViewInsertEventArgs e) { OnItemInserting (e); }
public void insert_item (object sender, FormViewInsertEventArgs e) { insertItem = true; }
private void fv_ItemInserting (object sender, FormViewInsertEventArgs e) { itemInserting = true; }
static void d_ItemInserting (object sender, FormViewInsertEventArgs e) { if (WebTest.CurrentTest.UserData == null) { ArrayList list = new ArrayList (); list.Add ("ItemInserting"); WebTest.CurrentTest.UserData = list; } else { ArrayList list = WebTest.CurrentTest.UserData as ArrayList; if (list == null) throw new NullReferenceException (); list.Add ("ItemInserting"); WebTest.CurrentTest.UserData = list; } }
protected void fvProductNoticeAdd_ItemInserting(object sender, FormViewInsertEventArgs e) { //取消原本的添加请求 e.Cancel = true; //检测是否含有session if (Session.Count < 5) { //跳转 Response.Redirect("/Account/Login", true); //停止加载后续内容 Response.End(); //直接返回 return; } //当前用户所在部门 string procName = Session["proc_name"].ToString(); //当前角色id Int16 roleId = Convert.ToInt16(Session["role_id"]); //检测是否有权限 if (procName != mustProcName || roleId < 0 || roleId > 4) { throw new Exception("您没有添加记录权限!"); } //检测是否需要保存表头 if (canEditHeadRow) { //设置录入员姓名和时间 e.Values["add_person"] = Session["user_name"].ToString(); e.Values["add_time"] = DateTime.Now; e.Values["last_change_time"] = DateTime.Now; } //根据输入的内容添加数据 if (InsertData(e)) { //调用过程执行跳转 fvProductNoticeAdd_ItemInserted(null, null); } }
/// <summary> /// 根据输入的内容添加数据到数据库 /// </summary> /// <param name="e">传入的带有数据的事件参数</param> /// <returns></returns> private bool InsertData(FormViewInsertEventArgs e) { //数据适配器 using (var daHead = new t_product_notice_headTableAdapter()) using (var daContent = new t_product_notice_contentTableAdapter()) using (var conn = daHead.Connection) { //打开数据库连接 conn.Open(); //设置数据库连接 daContent.Connection = conn; //开启事务 using (var tran = conn.BeginTransaction(IsolationLevel.RepeatableRead)) { //尝试运行 try { //设置事务 daHead.Transaction = daContent.Transaction = tran; //当前行单号 var billNum = Convert.ToString(e.Values["bill_num"]); //检测是否需要保存表身 if (canEditSonRow) { //获取表身内容 var rowId = Request.Form.GetValues("row_id"); var materialType = Request.Form.GetValues("material_type"); var materialCode = Request.Form.GetValues("material_code"); var materialName = Request.Form.GetValues("material_name"); var materialSize = Request.Form.GetValues("material_size"); var materialUnit = Request.Form.GetValues("material_unit"); var materialPnlLength = Request.Form.GetValues("material_pnl_length"); var materialPnlWidth = Request.Form.GetValues("material_pnl_width"); var materialPnlCountPcs = Request.Form.GetValues("material_pnl_count_pcs"); var materialPnlQty = Request.Form.GetValues("material_pnl_qty"); //取得表身内保存的行数 var iCountContentRow = 0; //遍历保存表身内容 for (int i = 0; i < rowId.Length; i++) { //有数据才保存 if ( materialType[i].Trim().Length > 0 || materialCode[i].Trim().Length > 0 || materialName[i].Trim().Length > 0 || materialUnit[i].Trim().Length > 0 || materialPnlLength[i].Trim().Length > 0 || materialPnlWidth[i].Trim().Length > 0 || materialPnlCountPcs[i].Trim().Length > 0 || materialPnlQty[i].Trim().Length > 0 ) { //执行保存 daContent.Insert( billNum, Convert.ToByte(rowId[i]), Convert.ToString(materialType[i]), Convert.ToString(materialCode[i]), Convert.ToString(materialName[i]), Convert.ToString(materialSize[i]), Convert.ToString(materialUnit[i]), Convert.ToDecimal(materialPnlLength[i]), Convert.ToDecimal(materialPnlWidth[i]), Convert.ToInt32(materialPnlCountPcs[i]), Convert.ToDecimal(materialPnlQty[i]) ); //累加行数 iCountContentRow++; } } //检测行数 if (iCountContentRow <= 0) { //抛出错误 throw new Exception("单据无内容不能保存!"); } } //检测是否需要保存表头 if (canEditHeadRow) { //保存表头 daHead.Insert( Convert.ToDateTime(e.Values["bill_date"]), billNum, Convert.ToString(e.Values["order_id"]), Convert.ToString(e.Values["remark"]), Convert.ToString(e.Values["add_person"]), Convert.ToDateTime(e.Values["add_time"]), Convert.ToDateTime(e.Values["last_change_time"]) ); } //提交事务 tran.Commit(); //返回成功 return true; } catch (Exception ex) { //回滚事务 tran.Rollback(); //抛出错误 throw ex; } } } }
/// <summary> /// 根据输入的参数保存到数据库 /// </summary> /// <param name="e">传入的带有数据的事件参数</param> /// <returns></returns> private bool InsertData(FormViewInsertEventArgs e) { //数据适配器 //当前添加语句对象 //当前数据库连接 using (var da = new t_proc_lot_card_balanceTableAdapter()) using (var daChange = new t_proc_lot_card_balance_changeTableAdapter()) using (var cmd = da.Adapter.InsertCommand) using (var conn = cmd.Connection) { //打开数据库连接 conn.Open(); //开启事务 using (var tran = conn.BeginTransaction()) { //设置事务 da.Transaction = daChange.Transaction = tran; //试运行 try { //执行保存数据 if (da.Insert( e.Values["prev_proc_name"].ToString(), e.Values["proc_name"].ToString(), e.Values["lot_id"].ToString(), e.Values["product_num"].ToString(), (int)e.Values["pnl_qty"], (int)e.Values["pcs_qty"], e.Values["remark"].ToString(), e.Values["add_person"].ToString(), (DateTime)e.Values["add_time"], (DateTime)e.Values["last_change_time"], e.Values["accept_person"].ToString(), (DateTime?)e.Values["accept_time"], (bool)e.Values["is_complete_wenzi"] ) <= 0) { //抛出错误 throw new Exception("添加部门批量卡结存发生错误!"); } //取得一个相关guid var guid = Guid.NewGuid().ToString(); //保存到修改记录表 if (daChange.InsertData( e.Values["prev_proc_name"].ToString(), e.Values["proc_name"].ToString(), e.Values["lot_id"].ToString(), e.Values["product_num"].ToString(), (int)e.Values["pnl_qty"], (int)e.Values["pcs_qty"], e.Values["remark"].ToString(), e.Values["add_person"].ToString(), e.Values["accept_person"].ToString(), (DateTime?)e.Values["accept_time"], (bool)e.Values["is_complete_wenzi"], true, guid ) <= 0) { //抛出错误 throw new Exception("添加修改批量卡结存日志记录发生错误!"); } //提交事务 tran.Commit(); //返回成功 return true; } catch (Exception ex) { //回滚事务 tran.Rollback(); //抛出错误 throw new Exception(ex.Message); } } } }
/// <summary> /// 根据输入的LOT格式来保存多条数据到数据库 /// </summary> /// <param name="e">传入的带有数据的事件参数</param> /// <param name="procName">当前部门名称</param> /// <returns></returns> private bool InsertData(FormViewInsertEventArgs e, string procName) { //当前用户输入的批量卡号 string strLotIdBegin = e.Values["lot_id"].ToString(); //当前用户输入的结束批量卡号 string strLotIdEnd = ((TextBox)fvProductRecordAdd.FindControl("txtLotIdEnd")).Text.Trim(); //数据适配器 //当前添加语句对象 //当前数据库连接 using (var da = new t_product_record_wenziTableAdapter()) using (var cmd = da.Adapter.InsertCommand) using (var conn = cmd.Connection) { //打开数据库连接 conn.Open(); //开启事务 using (var tran = conn.BeginTransaction()) { //设置事务 da.Transaction = tran; //试运行 try { //检测是否有结束批量卡号 if (strLotIdEnd.Length == 0) { //检测批量卡是否正确 //正则表达式 string strReg = @"^[1-9]\d(0[1-9]|1[012])-S?[1-9]\d{0,4}"; //检测是否正确批量卡号 if (!Regex.IsMatch(strLotIdBegin, strReg)) { //非数字返回失败 throw new Exception("您输入了一个不合格的批量卡号 " + strLotIdBegin + " !"); } //检测是否最小批量卡号 if (!ydPublicMethod.IsMinLotId(tran, procName, strLotIdBegin)) { //直接返回 return false; } //保存一条记录到数据库 if (!ydOperateBalanceLotCrad.InsertOneRecord(cmd, strLotIdBegin, e)) { //失败就直接返回 return false; } } else { //正则表达式 string strReg = @"^[1-9]\d{0,4}$"; //检测是否正确批量卡号 if (!Regex.IsMatch(strLotIdEnd, strReg)) { //非数字返回失败 throw new Exception("您输入了一个不合格的结束批量卡号 " + strLotIdEnd + " !"); } //检测是否样板 bool isSample = strLotIdBegin.ToUpper().Contains("S"); //批量卡中的年份月份和数字索引号 string strYearMonth; int iLotIdStart; int iLotIdEnd = int.Parse(strLotIdEnd); if (!isSample) { strYearMonth = strLotIdBegin.Substring(0, 5); iLotIdStart = int.Parse(strLotIdBegin.Substring(5)); } else { strYearMonth = strLotIdBegin.Substring(0, 6); iLotIdStart = int.Parse(strLotIdBegin.Substring(6)); } //检测起始和结束批量卡号,让起始批量卡号最小 if (iLotIdStart > iLotIdEnd) { int i = iLotIdStart; iLotIdStart = iLotIdEnd; iLotIdEnd = i; } //批量卡不能太多,不允许超过10张 if (iLotIdEnd - iLotIdStart > 10) { //不允许超过10张 throw new Exception( string.Format( "您输入批量卡号段 {0} 到 {1}{2} 的批量卡太多,不允许超过10张!", strLotIdBegin, strYearMonth, strLotIdEnd ) ); } //区分生产和样板来执行保存操作 if (!isSample) { //获取订单序号的数据适配器 using (var daGetOrderId = new t_ppc_lot_cardTableAdapter()) { //设置数据库连接 daGetOrderId.Connection = conn; //设置事务 daGetOrderId.Transaction = tran; //订单序号 string orderId = string.Empty; //检测输入的批量卡号段是否在同一个订单序号中 for (int i = iLotIdStart; i <= iLotIdEnd; i++) { //获取 var tab = daGetOrderId.GetDataByLotId(strYearMonth + i.ToString()); //检查结果 if (tab.Rows.Count == 0) { //报告失败 throw new Exception( string.Format( "您输入批量卡号段 {0} 到 {1}{2} 不存在!", strLotIdBegin, strYearMonth, strLotIdEnd ) ); } else { //首张批量卡号只获取不比较 if (i == iLotIdStart) { //取得订单序号 orderId = ((DataSetPpcLotCardMgr.t_ppc_lot_cardRow)tab.Rows[0]).order_id; } else if (orderId != ((DataSetPpcLotCardMgr.t_ppc_lot_cardRow)tab.Rows[0]).order_id) { //报告失败 throw new Exception( string.Format( "您输入批量卡号段 {0} 到 {1}{2} 中的{1}{3}跟其之前的批量卡不是一张订单!", strLotIdBegin, strYearMonth, strLotIdEnd, i ) ); } } } //当前报数的pnl数以及pcs数 int pnlQty = Convert.ToInt32(e.Values["pnl_qty"]); int pcsQty = Convert.ToInt32(e.Values["pcs_qty"]); //最后批量卡号 string strLotEnd = strYearMonth + iLotIdEnd.ToString(); //部门结余pnl总数及pcs总数 int totalPnlQty = 0; int totalPcsQty = 0; //检测最后一LOT板的数量必须为本部门结存的全部数量 ydOperateBalanceLotCrad.GetProcBalanceQty( tran, procName, strLotEnd, true, out totalPnlQty, out totalPcsQty ); //检测是否不等于该数量 if (pnlQty == totalPnlQty && pcsQty == totalPcsQty) { } else { //是否一样 bool isSame = false; if (pnlQty != totalPnlQty && pcsQty != totalPcsQty) { //获取pnl含pcs数 int pnlCountPcs = ydOperateBalanceLotCrad.GetPnlCountPcs(tran, strLotEnd); //检测是否一样 if (totalPnlQty * pnlCountPcs == pcsQty) { isSame = true; } } //不一样 if (!isSame) { //抛出错误 if (totalPnlQty > 0) { throw new Exception( string.Format( "如果有报结束批量卡号,则结束批量卡号({0})的数量必须为本部门总结存数 {1} pnl!", strLotEnd, totalPnlQty ) ); } else { throw new Exception( string.Format( "如果有报结束批量卡号,则结束批量卡号({0})的数量必须为本部门总结存数 {1} pcs!", strLotEnd, totalPcsQty ) ); } } } //执行保存 for (int i = iLotIdStart; i <= iLotIdEnd; i++) { //当前待保存的批量卡序号 string curLotId = strYearMonth + i.ToString(); //检测是否最小批量卡号 if (!ydPublicMethod.IsMinLotId(tran, procName, curLotId)) { //直接返回 return false; } //保存一条记录到数据库 if (!ydOperateBalanceLotCrad.InsertOneRecord(cmd, curLotId, e)) { //失败就直接返回 return false; } } } } else { //获取样板订单序号的数据适配器 using (var daGetOrderId = new t_sample_lot_cardTableAdapter()) { //设置数据库连接 daGetOrderId.Connection = conn; //设置事务 daGetOrderId.Transaction = tran; //样板订单序号 string orderId = string.Empty; //检测输入的批量卡号段是否在同一个订单序号中 for (int i = iLotIdStart; i <= iLotIdEnd; i++) { //获取 var tab = daGetOrderId.GetDataByLotId(strYearMonth + i.ToString()); //检查结果 if (tab.Rows.Count == 0) { //报告失败 throw new Exception( string.Format( "您输入的样板批量卡号段 {0} 到 {1}{2} 不存在!", strLotIdBegin, strYearMonth, strLotIdEnd ) ); } else { //首张批量卡号只获取不比较 if (i == iLotIdStart) { //取得订单序号 orderId = ((DAL.Sample.DataSetSampleLotCardMgr.t_sample_lot_cardRow)tab.Rows[0]).order_id; } else if (orderId != ((DAL.Sample.DataSetSampleLotCardMgr.t_sample_lot_cardRow)tab.Rows[0]).order_id) { //报告失败 throw new Exception( string.Format( "您输入的样板批量卡号段 {0} 到 {1}{2} 中的{1}{3}跟其之前的批量卡不是一张订单!", strLotIdBegin, strYearMonth, strLotIdEnd, i ) ); } } } //当前报数的pnl数以及pcs数 int pnlQty = Convert.ToInt32(e.Values["pnl_qty"]); int pcsQty = Convert.ToInt32(e.Values["pcs_qty"]); //最后批量卡号 string strLotEnd = strYearMonth + iLotIdEnd.ToString(); //部门结余pnl总数及pcs总数 int totalPnlQty = 0; int totalPcsQty = 0; //检测最后一LOT板的数量必须为本部门结存的全部数量 ydOperateBalanceLotCrad.GetProcBalanceQty( tran, procName, strLotEnd, true, out totalPnlQty, out totalPcsQty ); //检测是否不等于该数量 if (pnlQty == totalPnlQty && pcsQty == totalPcsQty) { } else { //是否一样 bool isSame = false; if (pnlQty != totalPnlQty && pcsQty != totalPcsQty) { //获取pnl含pcs数 int pnlCountPcs = ydOperateBalanceLotCrad.GetPnlCountPcs(tran, strLotEnd); //检测是否一样 if (totalPnlQty * pnlCountPcs == pcsQty) { isSame = true; } } //不一样 if (!isSame) { //抛出错误 if (totalPnlQty > 0) { throw new Exception( string.Format( "如果有报结束批量卡号,则结束批量卡号({0})的数量必须为本部门总结存数 {1} pnl!", strLotEnd, totalPnlQty ) ); } else { throw new Exception( string.Format( "如果有报结束批量卡号,则结束批量卡号({0})的数量必须为本部门总结存数 {1} pcs!", strLotEnd, totalPcsQty ) ); } } } //执行保存 for (int i = iLotIdStart; i <= iLotIdEnd; i++) { //当前待保存的批量卡序号 string curLotId = strYearMonth + i.ToString(); //检测是否最小批量卡号 if (!ydPublicMethod.IsMinLotId(tran, procName, curLotId)) { //直接返回 return false; } //保存一条记录到数据库 if (!ydOperateBalanceLotCrad.InsertOneRecord(cmd, curLotId, e)) { //失败就直接返回 return false; } } } } } //提交事务 tran.Commit(); //返回成功 return true; } catch (Exception ex) { //回滚事务 tran.Rollback(); //非数字返回失败 throw new Exception(ex.Message); } } } }
/// <summary> /// 保存多条lot卡开卡记录数据到数据库 /// </summary> /// <param name="e">传入的带有数据的事件参数</param> /// <returns></returns> private bool InsertData(FormViewInsertEventArgs e) { //当前用户输入的lot卡号 string strLotIdBegin = e.Values["lot_id"].ToString(); //正则表达式 string strReg = @"^[1-9]\d(0[1-9]|1[012])-[1-9]\d{0,4}"; //检测是否正确lot卡号 if (!Regex.IsMatch(strLotIdBegin, strReg)) { //非数字返回失败 throw new Exception("您输入了一个不合格的结束lot卡号 " + strLotIdBegin + " !"); } //数据适配器 //当前添加语句对象 //当前数据库连接 using (var da = new t_sample_lot_cardTableAdapter()) using (var daOrder = new t_sample_orderTableAdapter()) using (var daBalance = new t_dept_lot_card_balanceTableAdapter()) using (var conn = da.Connection) { //打开数据库连接 conn.Open(); //设置数据库连接 daOrder.Connection = daBalance.Connection = conn; //开启事务 using (var tran = conn.BeginTransaction()) { //设置事务 daOrder.Transaction = da.Transaction = daBalance.Transaction = tran; //试运行 try { //订单序号 string orderId = ((TextBox)fvSampleLotCardMgrAdd.FindControl("txtOrderId")).Text; //取得生产编号 string productNum = daOrder.GetProductNumByOrderId(orderId).ToString(); //lot卡中的年份月份和数字索引号 string strYearMonth = strLotIdBegin.Substring(0, 5); int iLotId = int.Parse(strLotIdBegin.Substring(5)); //每卡开多少pnl Int16 iEveryCardPnlQty = Int16.Parse(((TextBox)fvSampleLotCardMgrAdd.FindControl("txtEveryCardPnlQty")).Text); //是否补料单 bool isSupplement = Convert.ToBoolean(e.Values["is_supplement"]); //首部门 string firstDeptName = ((TextBox)fvSampleLotCardMgrAdd.FindControl("txtFirstDeptName")).Text; //备注 string remark = e.Values["remark"].ToString(); //录入员 string addPerson = e.Values["add_person"].ToString(); //录入时间 DateTime addTime = Convert.ToDateTime(e.Values["add_time"]); //录入时间 DateTime lastChangeTime = Convert.ToDateTime(e.Values["last_change_time"]); //遍历pnl数 foreach (var item in new string[] { "A", "B", "C", "D" }) { //pnl开料数 string pnlQty = ((TextBox)fvSampleLotCardMgrAdd.FindControl("txtPnlQty" + item)).Text; if (pnlQty.Length <= 0) { continue; } int iPnlQty = int.Parse(pnlQty); //pnl长 Int16 iPnlLength = Int16.Parse(((TextBox)fvSampleLotCardMgrAdd.FindControl("txtPnlLength" + item)).Text); //pnl宽 Int16 iPnlWidth = Int16.Parse(((TextBox)fvSampleLotCardMgrAdd.FindControl("txtPnlWidth" + item)).Text); //pnl含pcs数 Int16 iPnlCountPcs = Int16.Parse(((TextBox)fvSampleLotCardMgrAdd.FindControl("txtPnlCountPcs" + item)).Text); //开卡数 int iCountCard = iPnlQty / iEveryCardPnlQty; //尾卡数量太多,卡数+1 if (iPnlQty - iCountCard * iEveryCardPnlQty >= iEveryCardPnlQty * 0.5) { iCountCard++; } //开卡数至少一张 if (iCountCard <= 0) { iCountCard = 1; } //lot卡逐个往数据库填写 for (int i = iLotId; i < iLotId + iCountCard; i++) { //当前lot卡号 string lotId = strYearMonth + i; //当前卡开pnl数 Int16 iPnlQtyThis = i == iLotId + iCountCard - 1 ? (Int16)(iPnlQty - (iCountCard - 1) * iEveryCardPnlQty) : iEveryCardPnlQty; //写入当前lot卡 if (da.Insert( orderId, lotId, isSupplement, iPnlLength, iPnlWidth, iPnlCountPcs, iPnlQtyThis, firstDeptName, remark, addPerson, addTime, lastChangeTime ) <= 0) { //返回失败 throw new Exception(string.Format("插入lot卡 {0} 到数据库失败!", lotId)); } //写入部门结存 if (daBalance.Insert( "Sample", firstDeptName, lotId, productNum, iPnlQtyThis, 0, null, true, addPerson, addTime, lastChangeTime ) <= 0) { //返回失败 throw new Exception(string.Format("插入lot卡 {0} 到部门结存失败!", lotId)); } } //当前iLotId iLotId = iLotId + iCountCard; } //提交事务 tran.Commit(); //返回成功 return true; } catch (Exception ex) { //回滚事务 tran.Rollback(); //非数字返回失败 throw new Exception(ex.Message); } } } }
protected void fvProcLotCardMgrAdd_ItemInserting(object sender, FormViewInsertEventArgs e) { //默认取消请求 e.Cancel = true; //检测是否含有session if (Session.Count < 5) { //跳转 Response.Redirect("/Account/Login", true); //停止加载后续内容 Response.End(); //直接返回 return; } //当前用户所在部门 string procName = Session["proc_name"].ToString().ToUpper(); //当前角色id Int16 roleId = Convert.ToInt16(Session["role_id"]); //检测是否有权限 if ((procName != mustProcName && procName != "样板") || roleId < 0 || roleId > 1) { throw new Exception("您没有添加记录权限!"); } //当前输入的批量卡序号 string lotId = e.Values["lot_id"].ToString().Trim().ToUpper(); //检测是否样板 bool isSample = lotId.Contains("S"); //检测是否正确批量卡号 if (!isSample && !ydOperateLotCard.IsLotCardId(ref lotId)) { //非数字返回失败 throw new Exception("您输入了一个不合格的批量卡号 " + lotId + " !"); } //检测是否正确样板批量卡号 if (isSample && !ydOperateSampleLotCard.IsSampleLotCardId(ref lotId)) { //非数字返回失败 throw new Exception("您输入了一个不合格的样板批量卡号 " + lotId + " !"); } //检测lot卡类型 if (lotId.Contains("S") && procName != "样板") { throw new Exception("当前只能录入样板批量卡!"); } //检测lot卡类型 if (!lotId.Contains("S") && procName != "PMC") { throw new Exception("当前只能录入生产板批量卡!"); } //检测批量卡序号是否存在 if (ydOperateLotCard.IsExistLotId(lotId) || ydOperateSampleLotCard.IsExistSampleLotId(lotId)) { throw new Exception("当前批量卡号 " + lotId + " 已经存在!"); } //重新设置批量卡号(可能有添加上年份) e.Values["lot_id"] = lotId; //设置录入员姓名和时间 e.Values["add_person"] = Session["user_name"].ToString(); e.Values["add_time"] = DateTime.Now; e.Values["last_change_time"] = DateTime.Now; //根据输入的批量卡id执行添加数据 if (InsertData(e)) { //调用过程执行跳转 fvProcLotCardMgrAdd_ItemInserted(null, null); } }
protected void fvSampleLotCardMgrAdd_ItemInserting(object sender, FormViewInsertEventArgs e) { //取消原本的添加请求 e.Cancel = true; //检测是否含有session if (Session.Count < 5) { //跳转 Response.Redirect("/Account/Login", true); //停止加载后续内容 Response.End(); //直接返回 return; } //当前用户所在部门 string deptName = Session["dept_name"].ToString(); //当前角色id Int16 roleId = Convert.ToInt16(Session["role_id"]); //检测是否有权限 if (deptName != mustDeptName || roleId < 0 || (roleId > 4 && roleId != 6)) { throw new Exception("您没有添加记录权限!"); } //设置录入员姓名和时间 e.Values["add_person"] = Session["user_name"].ToString(); e.Values["add_time"] = DateTime.Now; e.Values["last_change_time"] = DateTime.Now; //根据输入的lot卡id执行添加数据 if (InsertData(e)) { //调用过程执行跳转 fvSampleLotCardMgrAdd_ItemInserted(null, null); } }
protected void fvUseWaterAdd_ItemInserting(object sender, FormViewInsertEventArgs e) { //取消请求执行自定义的方法 e.Cancel = true; if (!HasRight()) { throw new Exception("您没有添加记录权限!"); } //用户输入不合法不执行添加操作 if (!CheckUserInput()) { return; } //设置录入员姓名和时间 e.Values["add_person"] = Session["user_name"].ToString(); e.Values["add_time"] = DateTime.Now; e.Values["last_change_time"] = DateTime.Now; //直接保存 e.Cancel = false; }
protected void UserFormView_ItemInserting(object sender, FormViewInsertEventArgs e) { FormView userFormView = sender as FormView; if (UserFormView != null) { DropDownList departmentDropDownList = userFormView.FindControl("DepartmentDropDownList") as DropDownList; e.Values["DepartmentID"] = departmentDropDownList.SelectedValue.ToString(); DropDownList MemebershipRoleDropDownList = UserFormView.FindControl("MemebershipRoleDropDownList") as DropDownList; CheckBoxList MembershipRoleCheckBoxList = UserFormView.FindControl("MembershipRoleCheckBoxList") as CheckBoxList; string roles = string.Empty; foreach (ListItem item in MembershipRoleCheckBoxList.Items) { if (item.Selected) roles += item.Value + ","; } e.Values["Role"] = roles; } }
protected virtual new void OnItemInserting(FormViewInsertEventArgs e) { }
protected void fvCompleteBackAdd_ItemInserting(object sender, FormViewInsertEventArgs e) { //取消请求执行自定义的方法 e.Cancel = true; //检测是否含有session if (Session.Count < 5) { //跳转 Response.Redirect("/Account/Login", true); //停止加载后续内容 Response.End(); //直接返回 return; } //当前用户所在部门 string procName = Session["proc_name"].ToString(); //当前角色id Int16 roleId = Convert.ToInt16(Session["role_id"]); //检测是否有权限 if (procName != mustProcName || roleId < 0 || roleId > 4) { throw new Exception("您没有添加记录权限!"); } //用户输入不合法不执行添加操作 if (!CheckUserInput()) { return; } //当前部门名称 e.Values["proc_name"] = procName; //设置录入员姓名和时间 e.Values["add_person"] = Session["user_name"].ToString(); e.Values["add_time"] = e.Values["last_change_time"] = DateTime.Now; //根据输入的批量卡id执行添加数据 if (InsertData(e, procName)) { //调用过程执行跳转 fvCompleteBackAdd_ItemInserted(null, null); } }
/// <summary> /// 根据输入的LOT格式来保存多条数据到数据库 /// </summary> /// <param name="e">传入的带有数据的事件参数</param> /// <param name="procName">当前部门名称</param> /// <returns></returns> private bool InsertData(FormViewInsertEventArgs e, string procName) { //日期 DateTime billDate = Convert.ToDateTime(e.Values["bill_date"]); //单号 string billNum = Convert.ToString(e.Values["bill_num"]); //单据备注 string billRemark = Convert.ToString(e.Values["remark"]); //录入员 string addPerson = e.Values["add_person"].ToString(); //录入时间 DateTime addTime = Convert.ToDateTime(e.Values["add_time"]); //最后修改时间 DateTime lastChangeTime = Convert.ToDateTime(e.Values["last_change_time"]); //数据适配器 //当前添加语句对象 //当前数据库连接 using (var daHead = new t_complete_lot_card_back_headTableAdapter()) using (var daContent = new t_complete_lot_card_back_contentTableAdapter()) using (var daBalance = new t_complete_lot_card_balanceTableAdapter()) using (var conn = daHead.Connection) { //打开数据库连接 conn.Open(); //开启事务 using (var tran = conn.BeginTransaction()) { //设置数据库连接对象 daContent.Connection = daBalance.Connection = conn; //设置事务 daHead.Transaction = daContent.Transaction = daBalance.Transaction = tran; //试运行 try { //保存表头 daHead.Insert( billDate, billNum, procName, billRemark, addPerson, addTime, lastChangeTime ); //遍历子表执行保存 for (int iRow = 0; iRow < 10; iRow++) { //子表各控件 var tr = tabDataListSon.Rows[iRow + 1]; var litRowId = (Literal)tr.Cells[0].Controls[0]; var txtPrevProcName = (TextBox)tr.Cells[1].Controls[0]; var txtLotId = (TextBox)tr.Cells[2].Controls[0]; var txtProductNum = (TextBox)tr.Cells[3].Controls[0]; var txtPnlQty = (TextBox)tr.Cells[4].Controls[0]; var txtPcsQty = (TextBox)tr.Cells[5].Controls[0]; var txtRemark = (TextBox)tr.Cells[6].Controls[0]; //取得数据 byte rowId = Convert.ToByte(litRowId.Text); string prevProcName = txtPrevProcName.Text; string lotId = txtLotId.Text; string productNum = txtProductNum.Text; int pnlQty = txtPnlQty.Text.Trim().Length <= 0 ? 0 : int.Parse(txtPnlQty.Text.Trim()); int pcsQty = txtPcsQty.Text.Trim().Length <= 0 ? 0 : int.Parse(txtPcsQty.Text.Trim()); string remark = txtRemark.Text; //存在数据才保存 if (lotId.Length > 0 && productNum.Length > 0 && pnlQty + pcsQty > 0) { //保存到单据内容清单 daContent.Insert( billNum, rowId, prevProcName, lotId, productNum, pnlQty, pcsQty, remark ); //保存到成品结存清单 daBalance.InsertData( prevProcName, procName, lotId, productNum, pnlQty, pcsQty, "成品盘亏单写回" + (remark.Length <= 0 ? string.Empty : ":" + remark), addPerson ); } } //提交事务 tran.Commit(); //返回成功 return true; } catch (Exception ex) { //回滚事务 tran.Rollback(); //非数字返回失败 throw new Exception(ex.Message); } } } }
protected void fvEngLotCardAdd_ItemInserting(object sender, FormViewInsertEventArgs e) { //取消请求执行自定义的方法 e.Cancel = true; if (!HasRight()) { throw new Exception("您没有添加记录权限!"); } //检查用户输入并写入填写内容,输入不合法不执行添加操作 if (!CheckUserInput(e.Values) || !this.IsValid) { return; } //设置录入员姓名和时间 string user = Session["user_name"].ToString(); e.Values["add_person"] = user; e.Values["add_time"] = DateTime.Now; //当前角色id Int16 roleId = Convert.ToInt16(Session["role_id"]); //检测是否为审核权限 if (roleId < 4) { //审核人 e.Values["audit"] = user; //审核时间 e.Values["audit_time"] = DateTime.Now; } e.Values["last_change_time"] = DateTime.Now; //直接保存 e.Cancel = false; }