protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e)
        {
            e.NewValues["logtime"] = DateTime.Now.ToString();

            e.NewValues["clerkid"] = Convert.ToInt32(Session["UserId"]);
            e.NewValues["repairsheetid"] = Convert.ToInt32(e.OldValues["repairsheetid"]);
        }
        protected void fv_ItemUpdating(object sender, FormViewUpdateEventArgs e)
        {
            if (this.fv.CurrentMode == FormViewMode.Edit)
            {
                var employeesListControl = this.fv.FindControl("employeesList") as CheckBoxList;

                if (employeesListControl != null)
                {
                    var ctx = new PubsEntities();
                    var jobID = Convert.ToInt16(this.fv.DataKey["job_id"]);
                    var currentJob = ctx.jobs.First(x => x.job_id == jobID);

                    foreach (var item in employeesListControl.Items.OfType<ListItem>())
                    {
                        var employee = ctx.employees.First(x => x.emp_id == item.Value);

                        if (item.Selected)
                        {
                            employee.job_id = jobID;
                        }
                    }

                    ctx.SaveChanges();
                }
            }
        }
 protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e)
 {
     DropDownList title = (DropDownList)FormView1.FindControl("EditTitle");
       if (title != null)
       {
     e.NewValues.Add("TitleOfCourtesy", title.Text);
       }
 }
        protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e)
        {
            int tariffId = int.Parse(((DropDownList)FormView1.FindControl("TariffIdDropDownList")).SelectedValue);
            e.NewValues.Add("TariffId", tariffId);

            TextBox balanceTextBox = ((TextBox)FormView1.FindControl("BalanceTextBox"));
            if (balanceTextBox.Text == "")
                e.NewValues["Balance"] = (decimal?)0;
        }
 protected void frmCampoPlantilla_ItemUpdating(object sender, FormViewUpdateEventArgs e)
 {
     if (e.NewValues["CMP_LONGITUD_CABECERA"].ToString() == string.Empty)
     {
         e.NewValues["CMP_LONGITUD_CABECERA"] = null;
     }
     if (e.NewValues["CMP_POSICION_RELATIVA"].ToString() == string.Empty)
     {
         e.NewValues["CMP_POSICION_RELATIVA"] = null;
     }
 }
        protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e)
        {
            XmlDocument xdoc = XmlDataSource1.GetXmlDocument();
            XmlElement feed = xdoc.SelectSingleNode("feed/link[@name='" + e.OldValues[0].ToString() + "'][@url='" + e.OldValues[1].ToString() + "']") as XmlElement;
            feed.Attributes["url"].Value = e.NewValues["url"].ToString();

            XmlDataSource1.Save();
            XmlDataSource1.DataBind();

            e.Cancel = true;
            FormView1.ChangeMode(FormViewMode.ReadOnly);
        }
示例#7
0
    protected void fv_ItemUpdating(object sender, System.Web.UI.WebControls.FormViewUpdateEventArgs e)
    {
        FormView formView = (FormView)sender;
        Wizard   wzd      = (Wizard)formView.FindControl("wzd");
        TextBox  txt      = (TextBox)wzd.FindControl("txtCategoryName");

        e.NewValues["CategoryName"] = txt.Text.Trim();

        /*Online Demo Mode Restriction*/
        ClientScript.RegisterStartupScript(GetType(), "ANY_KEY", "alert('Data modifications are not allowed in online demos');", true);
        e.Cancel = true;
        /*Online Demo Mode Restriction*/
    }
        protected void FormViewSheetInfo_ItemUpdating(object sender, FormViewUpdateEventArgs e)
        {
            int state = Convert.ToInt32(e.NewValues["repairstateid"]);

            if (state >= 2 && state <= 4)
            { }
            else
            {
                Response.Write("<script language='javascript'>alert('没有权限修改此项内容!')</script>");
                //ClientScript.RegisterStartupScript(this.GetType(), "JS", "请阅读并勾选条款!");
                e.Cancel = true;
            }
        }
        protected void frmProtocolo_ItemUpdating(object sender, FormViewUpdateEventArgs e)
        {
            if (e.NewValues["PTR_PUERTO"].ToString() == string.Empty)
            {
                e.NewValues["PTR_PUERTO"] = null;
            }
            if (e.NewValues["PTR_TIMEOUT_REQUEST"].ToString() == string.Empty)
            {
                e.NewValues["PTR_TIMEOUT_REQUEST"] = null;
            }

            if (e.NewValues["PTR_TIMEOUT_RESPONSE"].ToString() == string.Empty)
            {
                e.NewValues["PTR_TIMEOUT_RESPONSE"] = null;
            }
        }
        /**
         * We are in "edit" mode, and the "Update" button was pressed
         * */
        protected void PGFV_ItemUpdating(Object sender, FormViewUpdateEventArgs e)
        {
            String id = ((TextBox)this.PGFV.FindControl("albumIdTextBox")).Text;
            String albumName = ((TextBox)this.PGFV.FindControl("albumNameTextBox")).Text;
            String albumDescription = ((TextBox)this.PGFV.FindControl("albumDescTextBox")).Text;

            //Update table
            controller.updateAlbum(Int32.Parse(id), albumName, albumDescription);

            //update the grid
            rebind(); //rebind the grid

            //Change the form view mode
            this.PGFV.ChangeMode(FormViewMode.ReadOnly);
            rebindForm(-1);
        }
 protected void fvSampleLotCardMgrAdd_ItemUpdating(object sender, FormViewUpdateEventArgs 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("您没有修改记录权限!");
     }
     //之前的lot卡号
     string oldLotId = e.OldValues["lot_id"].ToString().Trim();
     //当前要添加的lot卡号
     string newLotId = e.NewValues["lot_id"].ToString().Trim();
     //检测lot卡号是否存在
     if (newLotId != oldLotId && ydOperateSampleLotCard.IsExistSampleLotId(newLotId))
     {
         //报告失败
         return;
     }
     //设置录入员姓名和时间
     e.NewValues["add_person"] = Session["user_name"].ToString();
     e.NewValues["last_change_time"] = DateTime.Now;
     //允许添加
     e.Cancel = false;
 }
示例#12
0
 /// <summary>
 /// 根据输入的参数值来执行更新数据
 /// </summary>
 /// <param name="e">传入的带有数据的事件参数</param>
 /// <returns></returns>
 private bool UpdateData(FormViewUpdateEventArgs e)
 {
     //数据适配器
     //当前添加语句对象
     //当前数据库连接
     using (var da = new t_use_waterTableAdapter())
     using (var cmd = da.Adapter.UpdateCommand)
     using (var conn = cmd.Connection)
     {
         //打开数据库连接
         conn.Open();
         //开启事务
         using (var tran = conn.BeginTransaction())
         {
             //设置事务
             da.Transaction = tran;
             //试运行
             try
             {
                 //当前行id号
                 Int64 id = Convert.ToInt64(e.Keys["id"]);
                 //获取数据
                 using (var tab = da.GetDataById(id))
                 {
                     //检查是否获取到行
                     if (tab.Rows.Count == 0)
                     {
                         //显示失败
                         throw new Exception("当前生产记录已经被其他用户删除!");
                     }
                     else
                     {
                         //直接保存
                         e.Cancel = false;
                     }
                 }
                 //提交事务
                 tran.Commit();
                 //返回成功
                 return true;
             }
             catch (Exception ex)
             {
                 //回滚事务
                 tran.Rollback();
                 //非数字返回失败
                 throw new Exception(ex.Message);
             }
         }
     }
 }
示例#13
0
 protected void fvUseWaterAdd_ItemUpdating(object sender, FormViewUpdateEventArgs e)
 {
     //取消请求执行自定义的方法
     e.Cancel = true;
     if (!HasRight())
     {
         throw new Exception("您没有修改记录权限!");
     }
     //用户输入不合法不执行添加操作
     if (!CheckUserInput())
     {
         return;
     }
     //设置录入员姓名和时间
     e.NewValues["add_person"] = Session["user_name"].ToString();
     e.NewValues["last_change_time"] = DateTime.Now;
     //当前id号
     Int64 id = Convert.ToInt64(e.Keys[0]);
     //根据参数执行更新数据
     UpdateData(e);
 }
示例#14
0
 protected void fvCompleteBackAdd_ItemUpdating(object sender, FormViewUpdateEventArgs 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.NewValues["add_person"] = Session["user_name"].ToString();
     e.NewValues["last_change_time"] = DateTime.Now;
     //当前单号
     string billNum = Convert.ToString(e.Keys[0]);
     //根据参数执行更新数据
     if (UpdateData(e))
     {
         //调用过程执行跳转
         JumpToUrlByBillNum(billNum);
     }
 }
			public void DoOnItemUpdating (FormViewUpdateEventArgs e)
			{
				OnItemUpdating (e); 
			}
		private void fv_ItemUpdating (object sender, FormViewUpdateEventArgs e)
		{
			itemUpdating = true;
		}
示例#17
0
 protected void fvProductNoticeAdd_ItemUpdating(object sender, FormViewUpdateEventArgs 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 (!(new string[] { "PMC", mustProcName }).Contains(procName) || roleId < 0 || roleId > 4)
     {
         throw new Exception("您没有修改记录权限!");
     }
     //检测是否需要保存表头
     if (canEditHeadRow)
     {
         //设置录入员姓名和时间
         e.NewValues["add_person"] = Session["user_name"].ToString();
         e.NewValues["last_change_time"] = DateTime.Now;
     }
     //当前单号
     var billNum = Convert.ToString(e.Keys[0]);
     //根据参数执行更新数据
     if (UpdateData(e))
     {
         //调用过程执行跳转
         JumpToUrlByBillNum(billNum);
     }
 }
示例#18
0
        /// <summary>
        /// 根据输入的参数保存到数据库
        /// </summary>
        /// <param name="e">传入的带有数据的事件参数</param>
        /// <returns></returns>
        private bool UpdateData(FormViewUpdateEventArgs 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();
                //设置数据库连接
                da.Connection = daChange.Connection = cmd.Connection = conn;
                //开启事务
                using (var tran = conn.BeginTransaction())
                {
                    //设置事务
                    da.Transaction = daChange.Transaction = cmd.Transaction = tran;
                    //试运行
                    try
                    {
                        //执行保存数据
                        if (da.UpdateData(
                            e.NewValues["prev_proc_name"].ToString(),
                            e.NewValues["proc_name"].ToString(),
                            e.NewValues["lot_id"].ToString(),
                            e.NewValues["product_num"].ToString(),
                            Convert.ToInt32(e.NewValues["pnl_qty"]),
                            Convert.ToInt32(e.NewValues["pcs_qty"]),
                            e.NewValues["remark"] == null ? null : e.NewValues["remark"].ToString(),
                            e.NewValues["add_person"].ToString(),
                            Convert.ToDateTime(e.NewValues["add_time"]),
                            Convert.ToDateTime(e.NewValues["last_change_time"]),
                            e.NewValues["accept_person"] == null ? null : e.NewValues["accept_person"].ToString(),
                            e.NewValues["accept_time"] == null ? null : (DateTime?)e.NewValues["accept_time"],
                            Convert.ToBoolean(e.NewValues["is_complete_wenzi"]),
                            Convert.ToInt64(e.Keys[0])
                        ) <= 0)
                        {
                            //抛出错误
                            throw new Exception("修改部门批量卡结存发生错误!");
                        }
                        //取得一个相关guid
                        var guid = Guid.NewGuid().ToString();
                        //保存到修改记录表
                        if (daChange.InsertData(
                            e.OldValues["prev_proc_name"].ToString(),
                            e.OldValues["proc_name"].ToString(),
                            e.OldValues["lot_id"].ToString(),
                            e.OldValues["product_num"].ToString(),
                            Convert.ToInt32(e.OldValues["pnl_qty"]),
                            Convert.ToInt32(e.OldValues["pcs_qty"]),
                            e.OldValues["remark"] == null ? null : e.OldValues["remark"].ToString(),
                            e.OldValues["add_person"].ToString(),
                            e.OldValues["accept_person"] == null ? null : e.OldValues["accept_person"].ToString(),
                            e.OldValues["accept_time"] == null ? null : (DateTime?)e.OldValues["accept_time"],
                            Convert.ToBoolean(e.OldValues["is_complete_wenzi"]),
                            false,
                            guid
                        ) <= 0)
                        {
                            //抛出错误
                            throw new Exception("添加修改批量卡结存旧数据日志记录发生错误!");
                        }
                        //保存到修改记录表
                        if (daChange.InsertData(
                            e.NewValues["prev_proc_name"].ToString(),
                            e.NewValues["proc_name"].ToString(),
                            e.NewValues["lot_id"].ToString(),
                            e.NewValues["product_num"].ToString(),
                            Convert.ToInt32(e.NewValues["pnl_qty"]),
                            Convert.ToInt32(e.NewValues["pcs_qty"]),
                            e.NewValues["remark"] == null ? null : e.NewValues["remark"].ToString(),
                            e.NewValues["add_person"].ToString(),
                            e.NewValues["accept_person"] == null ? null : e.NewValues["accept_person"].ToString(),
                            e.NewValues["accept_time"] == null ? null : (DateTime?)e.NewValues["accept_time"],
                            Convert.ToBoolean(e.NewValues["is_complete_wenzi"]),
                            true,
                            guid
                        ) <= 0)
                        {
                            //抛出错误
                            throw new Exception("添加修改批量卡结存新数据日志记录发生错误!");
                        }

                        //提交事务
                        tran.Commit();
                        //返回成功
                        return true;
                    }
                    catch (Exception ex)
                    {
                        //回滚事务
                        tran.Rollback();
                        //抛出错误
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
        protected void fvReport_ItemUpdating(object sender, FormViewUpdateEventArgs e)
        {
            if (IsValid)
            {
                int id = Convert.ToInt32(((Label)fvReport.FindControl("lblRecordId")).Text);

                Tingle_WebForms.Models.MustIncludeForm myForm = ctx.MustIncludeForms.FirstOrDefault(eof => eof.RecordId == id);

                RadDropDownList ddlCompanyEdit = (RadDropDownList)fvReport.FindControl("ddlCompanyEdit");
                TextBox txtPO = (TextBox)fvReport.FindControl("txtPOEdit");
                TextBox txtArmstrongReference = (TextBox)fvReport.FindControl("txtArmstrongReferenceEdit");
                TextBox txtPattern = (TextBox)fvReport.FindControl("txtPatternEdit");
                TextBox txtLine = (TextBox)fvReport.FindControl("txtLineEdit");
                TextBox txtOrderNumber = (TextBox)fvReport.FindControl("txtOrderNumberEdit");
                TextBox txtCustomer = (TextBox)fvReport.FindControl("txtCustomerEdit");
                RadDropDownList ddlWarehouse = (RadDropDownList)fvReport.FindControl("ddlWarehouseEdit");
                HtmlInputText txtDueByDate = (HtmlInputText)fvReport.FindControl("txtDueByDateEdit");
                RadDropDownList ddlStatus = (RadDropDownList)fvReport.FindControl("ddlStatusEdit");
                int statusId = Convert.ToInt32(ddlStatus.SelectedValue);
                RadComboBox ddlRequestedByEdit = (RadComboBox)fvReport.FindControl("ddlRequestedByEdit");
                int requestedById = Convert.ToInt32(ddlRequestedByEdit.SelectedValue);
                RadComboBox ddlAssignedToEdit = (RadComboBox)fvReport.FindControl("ddlAssignedToEdit");
                int assignedToId = 0;
                if (ddlAssignedToEdit.SelectedIndex != -1)
                {
                    assignedToId = Convert.ToInt32(ddlAssignedToEdit.SelectedValue);
                }
                RadDropDownList ddlPriorityEdit = (RadDropDownList)fvReport.FindControl("ddlPriorityEdit");
                int priorityId = Convert.ToInt32(ddlPriorityEdit.SelectedValue);
                CheckBox cbSendComments = (CheckBox)fvReport.FindControl("cbSendComments");
                CheckBox cbShowSystemComments = (CheckBox)fvReport.FindControl("cbShowSystemComments");
                CheckBox cbNotifyStandard = (CheckBox)fvReport.FindControl("cbNotifyStandard");
                CheckBox cbNotifyAssignee = (CheckBox)fvReport.FindControl("cbNotifyAssignee");
                CheckBox cbNotifyOther = (CheckBox)fvReport.FindControl("cbNotifyOther");
                CheckBox cbNotifyRequester = (CheckBox)fvReport.FindControl("cbNotifyRequester");
                RadComboBox ddlNotifyOther = (RadComboBox)fvReport.FindControl("ddlNotifyOther");

                Label lblEmailsSentTo = (Label)fvReport.FindControl("lblEmailsSentTo");
                Label lblFVMessage = (Label)fvReport.FindControl("lblFVMessage");

                DateTime tryDateDue;
                Nullable<DateTime> dateDue = null;

                try
                {
                    if (myForm.RequestedUser.SystemUserID.ToString() != ddlRequestedByEdit.SelectedValue)
                    {
                        Comments newRequesterComment = new Comments
                        {
                            Form = ctx.TForms.FirstOrDefault(x => x.FormName == "Must Include"),
                            Note = "Requester Changed To: " + ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == requestedById).DisplayName,
                            RelatedFormId = myForm.RecordId,
                            SystemComment = true,
                            Timestamp = DateTime.Now
                        };

                        ctx.Comments.Add(newRequesterComment);
                    }

                    if (myForm.AssignedUser == null && ddlAssignedToEdit.SelectedIndex != -1) // (myForm.AssignedUser != null && ddlAssignedToEdit.SelectedIndex != -1 && Convert.ToString(myForm.AssignedUser.SystemUserID) != ddlAssignedToEdit.SelectedValue))
                    {
                        Comments newAssignedComment = new Comments
                        {
                            Form = ctx.TForms.FirstOrDefault(x => x.FormName == "Must Include"),
                            Note = "Request Assigned To: " + ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == assignedToId).DisplayName,
                            RelatedFormId = myForm.RecordId,
                            SystemComment = true,
                            Timestamp = DateTime.Now
                        };

                        ctx.Comments.Add(newAssignedComment);
                    }
                    else if (myForm.AssignedUser != null && ddlAssignedToEdit.SelectedIndex != -1)
                    {
                        if (myForm.AssignedUser.SystemUserID.ToString() != ddlAssignedToEdit.SelectedValue)
                        {
                            Comments newAssignedComment = new Comments
                            {
                                Form = ctx.TForms.FirstOrDefault(x => x.FormName == "Must Include"),
                                Note = "Request Assignee Changed To: " + ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == assignedToId).DisplayName,
                                RelatedFormId = myForm.RecordId,
                                SystemComment = true,
                                Timestamp = DateTime.Now
                            };

                            ctx.Comments.Add(newAssignedComment);
                        }
                    }
                    else if (myForm.AssignedUser != null && ddlAssignedToEdit.SelectedIndex == -1)
                    {
                        Comments newAssignedComment = new Comments
                        {
                            Form = ctx.TForms.FirstOrDefault(x => x.FormName == "Must Include"),
                            Note = "Request Assignment Removed From: " + ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == myForm.AssignedUser.SystemUserID).DisplayName,
                            RelatedFormId = myForm.RecordId,
                            SystemComment = true,
                            Timestamp = DateTime.Now
                        };

                        ctx.Comments.Add(newAssignedComment);
                    }

                    if (txtDueByDate.Value != null)
                    {
                        DateTime.TryParse(txtDueByDate.Value.ToString(), out tryDateDue);
                        if (tryDateDue.Year > 0001)
                        {
                            dateDue = tryDateDue;
                        }
                    }

                    var statusCode = ctx.Statuses.FirstOrDefault(s => s.StatusId == statusId);

                    myForm.Company = ddlCompanyEdit.SelectedValue;
                    myForm.PO = txtPO.Text;
                    myForm.ArmstrongReference = txtArmstrongReference.Text;
                    myForm.Pattern = txtPattern.Text;
                    myForm.Line = txtLine.Text;
                    myForm.OrderNumber = txtOrderNumber.Text;
                    myForm.Customer = txtCustomer.Text;
                    myForm.Warehouse = ctx.Warehouses.FirstOrDefault(x => x.WarehouseText == ddlWarehouse.SelectedText);
                    myForm.Status = statusCode;
                    myForm.RequestedUser = ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == requestedById);
                    myForm.Priority = ctx.Priorities.FirstOrDefault(x => x.RecordId == priorityId);
                    myForm.DueDate = dateDue;

                    if (ddlAssignedToEdit.SelectedIndex != -1)
                    {
                        myForm.AssignedUser = ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == assignedToId);
                    }
                    else
                    {
                        myForm.AssignedUser = null;
                    }

                    myForm.LastModifiedTimestamp = DateTime.Now;
                    UserLogic newLogic = new UserLogic();
                    System.Security.Principal.IPrincipal user = System.Web.HttpContext.Current.User;
                    SystemUsers currentUser = newLogic.GetCurrentUser(user);
                    myForm.LastModifiedUser = ctx.SystemUsers.FirstOrDefault(x => x.SystemUserID == currentUser.SystemUserID);

                    ctx.MustIncludeForms.Attach(myForm);
                    ctx.Entry(myForm).State = EntityState.Modified;

                    ctx.SaveChanges();

                    if (myForm.AssignedUser != null && !newLogic.HasBeenAssigned(myForm.AssignedUser, myForm.RecordId, "Must Include"))
                    {
                        UserAssignmentAssociation uA = new UserAssignmentAssociation
                        {
                            Form = ctx.TForms.FirstOrDefault(x => x.FormName == "Must Include"),
                            RelatedFormId = myForm.RecordId,
                            User = myForm.AssignedUser
                        };

                        ctx.UserAssignments.Add(uA);
                    }

                    if (myForm.RequestedUser != null && !newLogic.HasBeenRequested(myForm.RequestedUser, myForm.RecordId, "Must Include"))
                    {
                        UserRequestAssociation uR = new UserRequestAssociation
                        {
                            Form = ctx.TForms.FirstOrDefault(x => x.FormName == "Must Include"),
                            RelatedFormId = myForm.RecordId,
                            User = myForm.RequestedUser
                        };

                        ctx.UserRequests.Add(uR);
                    }

                    ctx.SaveChanges();

                    if (myForm.Status.StatusText == "Completed")
                    {
                        Comments updateComment = new Comments
                        {
                            Form = ctx.TForms.FirstOrDefault(x => x.FormName == "Must Include"),
                            Note = "Request Completed By: " + currentUser.DisplayName,
                            RelatedFormId = myForm.RecordId,
                            SystemComment = true,
                            Timestamp = DateTime.Now
                        };

                        ctx.Comments.Add(updateComment);

                    }
                    else
                    {
                        Comments updateComment = new Comments
                        {
                            Form = ctx.TForms.FirstOrDefault(x => x.FormName == "Must Include"),
                            Note = "Request Updated By: " + currentUser.DisplayName + " --- Status: " + myForm.Status.StatusText + " --- Priority: " + myForm.Priority.PriorityText,
                            RelatedFormId = myForm.RecordId,
                            SystemComment = true,
                            Timestamp = DateTime.Now
                        };

                        ctx.Comments.Add(updateComment);
                    }

                    if (lblEmailsSentTo.Text != "")
                    {
                        SendUpdateEmail(myForm.RecordId, lblEmailsSentTo.Text, cbSendComments.Checked, cbShowSystemComments.Checked);

                        Comments notificationComment = new Comments
                        {
                            Form = ctx.TForms.FirstOrDefault(x => x.FormName == "Must Include"),
                            Note = "Request Notifications Sent To: " + lblEmailsSentTo.Text,
                            RelatedFormId = myForm.RecordId,
                            SystemComment = true,
                            Timestamp = DateTime.Now
                        };

                        ctx.Comments.Add(notificationComment);
                    }

                    ctx.SaveChanges();

                    cbNotifyAssignee.Checked = false;
                    cbNotifyOther.Checked = false;
                    cbNotifyRequester.Checked = false;
                    cbNotifyStandard.Checked = false;
                    cbSendComments.Checked = false;
                    ddlNotifyOther.Text = "";

                    gvReport.DataBind();
                    gvReport.SelectedIndex = -1;
                    pnlDetails.Visible = false;
                    pnlReport.Visible = true;
                    pnlFilter.Visible = true;
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
        }
 protected virtual new void OnItemUpdating(FormViewUpdateEventArgs e)
 {
 }
示例#21
0
 protected void fvProcLotCardMgrAdd_ItemUpdating(object sender, FormViewUpdateEventArgs 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 lotIdOld = e.OldValues["lot_id"].ToString().Trim();
     //当前要添加的批量卡序号
     string lotIdNew = e.NewValues["lot_id"].ToString().Trim();
     //不能从样板批量卡修改为生产板批量卡,反之亦然
     if (lotIdNew.Contains("S") != lotIdOld.Contains("S"))
     {
         throw new Exception("不能从样板批量卡修改为生产板批量卡,反之亦然!");
     }
     //检测lot卡类型
     if (lotIdOld.Contains("S") && procName != "样板")
     {
         throw new Exception("当前只能修改样板批量卡!");
     }
     //检测lot卡类型
     if (!lotIdOld.Contains("S") && procName != "PMC")
     {
         throw new Exception("当前只能修改生产板批量卡!");
     }
     //检测是否正确批量卡号
     if (!ydOperateLotCard.IsLotCardId(ref lotIdNew) && !ydOperateSampleLotCard.IsSampleLotCardId(ref lotIdNew))
     {
         //非数字返回失败
         throw new Exception("您输入了一个不合格的批量卡号 " + lotIdNew + " !");
     }
     //检测批量卡序号是否存在
     if (lotIdNew != lotIdOld &&
         (ydOperateLotCard.IsExistLotId(lotIdNew) || ydOperateSampleLotCard.IsExistSampleLotId(lotIdNew))
     )
     {
         //报告失败
         throw new Exception("当前批量卡号 " + lotIdNew + " 已经存在!");
     }
     //重新设置批量卡号(可能有添加上年份)
     e.NewValues["lot_id"] = lotIdNew;
     //设置录入员姓名和时间
     e.NewValues["add_person"] = Session["user_name"].ToString();
     e.NewValues["last_change_time"] = DateTime.Now;
     //根据输入的批量卡id执行添加数据
     if (UpdateData(e))
     {
         //调用过程执行跳转
         fvProcLotCardMgrAdd_ItemInserted(null, null);
     }
 }
示例#22
0
        /// <summary>
        /// 根据输入的参数值来执行更新数据
        /// </summary>
        /// <param name="e">传入的带有数据的事件参数</param>
        /// <returns></returns>
        private bool UpdateData(FormViewUpdateEventArgs e)
        {
            //数据适配器
            //当前添加语句对象
            //当前数据库连接
            using (var da = new v_material_outTableAdapter())
            using (var conn = da.Connection)
            {
                //打开数据库连接
                conn.Open();
                //开启事务
                using (var tran = conn.BeginTransaction())
                {
                    //设置事务
                    da.Transaction = tran;
                    //试运行
                    try
                    {
                        //当前行单号
                        string billNum = Convert.ToString(e.Keys[0]);
                        //获取数据
                        using (var tab = da.GetDataByBillNum(billNum))
                        {
                            //检查是否获取到行
                            if (tab.Rows.Count == 0)
                            {
                                //显示失败
                                throw new Exception("当前记录已经被其他用户删除!");
                            }
                            //数据适配器
                            using (var daHead = new t_material_out_headTableAdapter())
                            using (var daContent = new t_material_out_contentTableAdapter())
                            using (var daBalance = new t_material_balanceTableAdapter())
                            {
                                //设置数据库连接
                                daHead.Connection = daContent.Connection = daBalance.Connection = conn;
                                //设置事务
                                daHead.Transaction = daContent.Transaction = daBalance.Transaction = tran;
                                //遍历行执行添加到结存记录
                                foreach (DataSetMaterialOut.v_material_outRow row in tab.Rows)
                                {
                                    //执行添加结存
                                    if (!ydOperateMaterial.AddMaterialBalance(
                                        tran,
                                        BillType.Out,
                                        row.bill_num,
                                        row.row_id
                                    ))
                                    {
                                        return false;
                                    }
                                }
                                //从单据内容中删除
                                if (daContent.DeleteByBillNum(billNum) <= 0)
                                {
                                    throw new Exception("从单据内容中删除失败!");
                                }
                                //从单据表头中删除
                                if (daHead.Delete(billNum) <= 0)
                                {
                                    throw new Exception("从单据表头中删除失败!");
                                }

                                //日期
                                DateTime billDate = Convert.ToDateTime(e.NewValues["bill_date"]);
                                //部门序号
                                byte procId = Convert.ToByte(e.NewValues["proc_id"]);
                                //部门名称
                                string procName = Convert.ToString(e.NewValues["proc_name"]);
                                //单据备注
                                string billRemark = Convert.ToString(e.NewValues["remark"]);
                                //录入员
                                string addPerson = e.NewValues["add_person"].ToString();
                                //录入时间
                                DateTime addTime = Convert.ToDateTime(e.NewValues["add_time"]);
                                //最后修改时间
                                DateTime lastChangeTime = Convert.ToDateTime(e.NewValues["last_change_time"]);
                                //含有数据的行数
                                int iCountContent = 0;
                                //遍历子表执行保存
                                for (int iRow = 0; iRow < 10; iRow++)
                                {
                                    //子表各控件
                                    var tr = tabDataListSon.Rows[iRow + 1];
                                    var litRowId = (Literal)tr.Cells[0].Controls[0];
                                    var txtSupplierCode = (TextBox)tr.Cells[1].Controls[0];
                                    var txtSupplierName = (TextBox)tr.Cells[2].Controls[0];
                                    var txtMaterialCode = (TextBox)tr.Cells[3].Controls[0];
                                    var txtMaterialName = (TextBox)tr.Cells[4].Controls[0];
                                    var txtMaterialSize = (TextBox)tr.Cells[5].Controls[0];
                                    var txtQty = (TextBox)tr.Cells[6].Controls[0];
                                    var txtMaterialUnit = (TextBox)tr.Cells[7].Controls[0];
                                    var hfPrice = (HiddenField)tr.Cells[8].Controls[0];
                                    var txtRemark = (TextBox)tr.Cells[9].Controls[0];
                                    //取得数据
                                    byte rowId = Convert.ToByte(litRowId.Text);
                                    string supplierCode = txtSupplierCode.Text;
                                    string supplierName = txtSupplierName.Text;
                                    string materialCode = txtMaterialCode.Text;
                                    string materialName = txtMaterialName.Text;
                                    string materialSize = txtMaterialSize.Text;
                                    decimal qty = txtQty.Text.Trim().Length <= 0 ? 0m : decimal.Parse(txtQty.Text.Trim());
                                    string materialUnit = txtMaterialUnit.Text;
                                    decimal price = hfPrice.Value.Trim().Length <= 0 ? 0m : decimal.Parse(hfPrice.Value.Trim());
                                    string remark = txtRemark.Text;
                                    //存在数据才保存
                                    if (materialCode.Length > 0 && materialName.Length > 0 && materialUnit.Length > 0 && qty > 0)
                                    {
                                        //从原料结存清单扣数
                                        if (!ydOperateMaterial.DecreaseMaterialBalance(
                                            daBalance,
                                            BillType.Out,
                                            supplierName,
                                            materialName,
                                            price,
                                            qty
                                        ))
                                        {
                                            return false;
                                        }
                                        //保存到单据内容清单
                                        if (daContent.Insert(
                                            billNum,
                                            rowId,
                                            supplierCode,
                                            supplierName,
                                            materialCode,
                                            materialName,
                                            materialSize,
                                            qty,
                                            materialUnit,
                                            price,
                                            remark
                                        ) <= 0)
                                        {
                                            throw new Exception("保存到单据内容清单失败!");
                                        }
                                        //含有数据的行数计数
                                        iCountContent++;
                                    }
                                }

                                //保存表头
                                if (iCountContent > 0)
                                {
                                    if (daHead.Insert(
                                        billDate,
                                        billNum,
                                        procId,
                                        procName,
                                        billRemark,
                                        addPerson,
                                        addTime,
                                        lastChangeTime
                                    ) <= 0)
                                    {
                                        throw new Exception("保存到单据表头清单失败!");
                                    }
                                }
                            }
                        }
                        //提交事务
                        tran.Commit();
                        //返回成功
                        return true;
                    }
                    catch (Exception ex)
                    {
                        //回滚事务
                        tran.Rollback();
                        //非数字返回失败
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
示例#23
0
 /// <summary>
 /// 根据输入的参数值来执行更新数据
 /// </summary>
 /// <param name="e">传入的带有数据的事件参数</param>
 /// <returns></returns>
 private bool UpdateData(FormViewUpdateEventArgs e)
 {
     //检测是否更改了需要更新到其他部门的数据内容
     if (e.OldValues["lot_id"].Equals(e.NewValues["lot_id"]) &&
         e.OldValues["product_num"].Equals(e.NewValues["product_num"]) &&
         e.OldValues["pnl_qty"].Equals(e.NewValues["pnl_qty"]) &&
         e.OldValues["next_proc_name"].Equals(e.NewValues["next_proc_name"])
     )
     {
         //执行只更新本生产记录
         e.Cancel = false;
         //更新事件继续执行
         return false;
     }
     //数据适配器
     //当前添加语句对象
     //当前数据库连接
     using (var da = new t_product_record_wenziTableAdapter())
     using (var cmd = da.Adapter.UpdateCommand)
     using (var conn = cmd.Connection)
     {
         //打开数据库连接
         conn.Open();
         //开启事务
         using (var tran = conn.BeginTransaction())
         {
             //设置事务
             da.Transaction = tran;
             //试运行
             try
             {
                 //部门名称
                 string procName = e.OldValues["proc_name"].ToString();
                 //当前行id号
                 Int64 id = Convert.ToInt64(e.Keys["id"]);
                 //获取数据
                 using (var tab = da.GetDataById(id))
                 {
                     //检查是否获取到行
                     if (tab.Rows.Count == 0)
                     {
                         //显示失败
                         throw new Exception("当前生产记录已经被其他用户删除!");
                     }
                     else
                     {
                         //首行
                         var row = (DataSetProductRecord.t_product_record_wenziRow)tab.Rows[0];
                         //下部门名称
                         string nextProcName = row.next_proc_name;
                         //批量卡序号
                         string lotId = row.lot_id;
                         //pnl出数
                         int pnlQty = row.pnl_qty;
                         //pcs出数
                         int pcsQty = row.pcs_qty;
                         //检测是否超过下部门余数
                         if (ydOperateBalanceLotCrad.IsOutstripProcBalance(
                             tran,
                             nextProcName,
                             lotId,
                             false,
                             pnlQty,
                             pcsQty
                         ))
                         {
                             return false;
                         }
                         //修改下部门批量卡余数
                         if (!ydOperateBalanceLotCrad.UpdateBalanceAfterInsert(
                             tran,
                             nextProcName,
                             lotId,
                             false,
                             pnlQty,
                             pcsQty
                         ))
                         {
                             return false;
                         }
                         //目标数据库表名
                         string toTabName = nextProcName == "成品仓" ? "[t_complete_lot_card_wait]" : "[t_proc_lot_card_balance]";
                         //添加到部门结存批量卡
                         if (!ydOperateBalanceLotCrad.InsertOneRecordToLotCardBalance(
                             tran,
                             ydOperateBalanceLotCrad.GetTabNameByProcName(procName),
                             procName,
                             toTabName,
                             id,
                             true
                         ))
                         {
                             return false;
                         }
                     }
                 }
                 //部门名称
                 procName = e.NewValues["proc_name"].ToString();
                 //保存一条记录到数据库
                 if (!ydOperateBalanceLotCrad.UpdateOneRecord(cmd, e, procName))
                 {
                     //失败就直接返回
                     return false;
                 }
                 //提交事务
                 tran.Commit();
                 //返回成功
                 return true;
             }
             catch (Exception ex)
             {
                 //回滚事务
                 tran.Rollback();
                 //非数字返回失败
                 throw new Exception(ex.Message);
             }
         }
     }
 }
示例#24
0
 protected void formviewAccount_OnItemUpdating(object sender, FormViewUpdateEventArgs e)
 {
     var frmAccount = sender as FormView;
     if (frmAccount == null)
         return;
     var cancelSubscriptionOption = frmAccount.FindControl("CancelSubscriptionRadioButton") as RadioButton;
     if (cancelSubscriptionOption != null && cancelSubscriptionOption.Checked)
     {
         //the cancel subscription process is done right here, we mustn't update anything
         return;
     }
     var subscriptionSelected = frmAccount.FindControl("SubscriptionLevelHiddenField") as HiddenField;
     int subscriptionLevelId;
     if (subscriptionSelected != null && int.TryParse(subscriptionSelected.Value, out subscriptionLevelId))
     {
         var oldSubscriptionLevelId = e.OldValues["SubscriptionLevelId"] as int?;
         //Only if the new subscripton is greater than before
         if (oldSubscriptionLevelId.HasValue && oldSubscriptionLevelId.Value > subscriptionLevelId)
         {
             var promocode = frmAccount.FindControl("PromotionCodeTextBox") as TextBox;
             e.NewValues["SubscriptionLevelId"] = subscriptionLevelId;
             if (promocode != null && promocode.Text.Length > 0)
             {
                 var promoCodeStatus = PromoCodeManager.Validate(promocode.Text, subscriptionLevelId, IdAccount);
                 if (promoCodeStatus.StatusCode != StatusCode.Found)
                 {
                     e.Cancel = true;
                     return;
                 }
             }
         }
     }
     var dropdownlistCompanyCountry = frmAccount.FindControl("DropDownListCompanyCountry") as DropDownList;
     if (dropdownlistCompanyCountry == null || dropdownlistCompanyCountry.SelectedValue == "-1")
         return;
     e.NewValues["CompanyIdCountry"] = dropdownlistCompanyCountry.SelectedValue;
     var frmBilling = sender as FormView;
     if (frmBilling == null)
         return;
     var dropdownlistCreditCardCountry =
         frmBilling.FindControl("DropDownListCreditCardIdCountry") as DropDownList;
     if (dropdownlistCreditCardCountry != null && dropdownlistCreditCardCountry.SelectedValue != "-1")
     {
         e.NewValues["CreditCardIdCountry"] = dropdownlistCreditCardCountry.SelectedValue;
     }
     var dropDownListCreditCardType = frmBilling.FindControl("dropDownListCreditCardType") as DropDownList;
     if (dropDownListCreditCardType != null && dropDownListCreditCardType.SelectedValue != "-1")
     {
         e.NewValues["CreditCardType"] =
             AccountManager.GetCreditCardTypeById(dropDownListCreditCardType.SelectedValue);
     }
     var creditCardNumberTextBox = frmBilling.FindControl("TextBoxCreditCardNumber") as TextBox;
     if (creditCardNumberTextBox != null && !string.IsNullOrEmpty(creditCardNumberTextBox.Text))
     {
         e.NewValues["CreditCardNumber"] = new string('x', creditCardNumberTextBox.Text.Length - 4) +
                                           creditCardNumberTextBox.Text.Substring(
                                               creditCardNumberTextBox.Text.Length - 4);
     }
     var creditCardExpirationSelect = frmBilling.FindControl("MonthExpirationDate") as OptionGroupSelect;
     if (creditCardExpirationSelect != null)
     {
         e.NewValues["CreditCardExpiration"] =
             creditCardExpirationSelect.SelectedValue;
     }
 }
示例#25
0
        /// <summary>
        /// 根据输入的参数值来执行更新数据
        /// </summary>
        /// <param name="e">传入的带有数据的事件参数</param>
        /// <returns></returns>
        private bool UpdateData(FormViewUpdateEventArgs 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())
                {
                    //设置事务
                    daHead.Transaction = daContent.Transaction = tran;
                    //试运行
                    try
                    {
                        //当前行单号
                        string billNum = Convert.ToString(e.Keys[0]);
                        //检测是否需要保存表头
                        if (canEditHeadRow)
                        {
                            //从单据表头中删除
                            if (daHead.Delete(billNum) <= 0)
                            {
                                throw new Exception("从单据表头中删除失败!");
                            }
                            //保存表头
                            daHead.Insert(
                                Convert.ToDateTime(e.NewValues["bill_date"]),
                                billNum,
                                Convert.ToString(e.NewValues["order_id"]),
                                Convert.ToString(e.NewValues["remark"]),
                                Convert.ToString(e.NewValues["add_person"]),
                                Convert.ToDateTime(e.NewValues["add_time"]),
                                Convert.ToDateTime(e.NewValues["last_change_time"])
                            );
                        }
                        //检测是否需要保存表身
                        if (canEditSonRow)
                        {
                            //从单据内容中删除
                            if (daContent.DeleteByBillNum(billNum) <= 0)
                            {
                                //throw new Exception("从单据内容中删除失败!");
                            }

                            //获取表身内容
                            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("单据无内容不能保存!");
                            }
                        }
                        //提交事务
                        tran.Commit();
                        //返回成功
                        return true;
                    }
                    catch (Exception ex)
                    {
                        //回滚事务
                        tran.Rollback();
                        //非数字返回失败
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
示例#26
0
 protected void fvScrapCodeAdd_ItemUpdating(object sender, FormViewUpdateEventArgs 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)
     {
         throw new Exception("您没有修改记录权限!");
     }
     //设置录入员姓名和时间
     e.NewValues["add_person"] = Session["user_name"].ToString();
     e.NewValues["last_change_time"] = DateTime.Now;
     //允许执行更新
     e.Cancel = false;
 }
		static void d_ItemUpdating (object sender, FormViewUpdateEventArgs e)
		{
			if (WebTest.CurrentTest.UserData == null) {
				ArrayList list = new ArrayList ();
				list.Add ("ItemUpdating");
				WebTest.CurrentTest.UserData = list;
			}
			else {
				ArrayList list = WebTest.CurrentTest.UserData as ArrayList;
				if (list == null)
					throw new NullReferenceException ();
				list.Add ("ItemUpdating");
				WebTest.CurrentTest.UserData = list;
			}
		}
 protected void FormView_report_ItemUpdating(object sender, FormViewUpdateEventArgs e)
 {
     e.NewValues["modifytime"] = DateTime.Now.ToString();
     e.NewValues["clerkid"] = Convert.ToInt32(Session["UserId"]);
     //e.NewValues["repairsheetid"] = SheetId;// Convert.ToInt32(Request["id"]);
     e.NewValues["productname"] = "";
     e.NewValues["productnumber"] = "";
 }
		public void update_item (object sender, FormViewUpdateEventArgs e)
		{
			updateItem = true;
		}
示例#30
0
 protected void fvEngLotCardAdd_ItemUpdating(object sender, FormViewUpdateEventArgs e)
 {
     //取消请求执行自定义的方法
     e.Cancel = true;
     if (!HasRight())
     {
         throw new Exception("您没有修改记录权限!");
     }
     //当前生产编号
     string pn = string.Empty;
     //当前ID
     long id = Convert.ToInt32(e.Keys["id"]);
     //获取生产编号
     using (var da = new t_eng_lot_cardTableAdapter())
     {
         var tab = da.GetDataById(id);
         if (tab.Rows.Count == 0)
         {
             throw new Exception("修改失败,此条记录已经被其他用户删除!");
         }
         var row = (DataSetEng.t_eng_lot_cardRow)tab.Rows[0];
         pn = row.product_num;
     }
     var col = e.NewValues;
     //检查用户输入并写入填写内容,输入不合法不执行修改操作
     if (!CheckUserInput(e.NewValues, pn) || !this.IsValid)
     {
         return;
     }
     //记录生产编号
     e.NewValues["product_num"] = pn;
     //设置录入员姓名和时间
     string user = Session["user_name"].ToString();
     //当前角色id
     Int16 roleId = Convert.ToInt16(Session["role_id"]);
     //检测是否为审核权限
     if (roleId < 4)
     {
         //审核人
         e.NewValues["audit"] = user;
         //审核时间
         e.NewValues["audit_time"] = DateTime.Now;
     }
     else
     {
         e.NewValues["add_person"] = user;
     }
     e.NewValues["last_change_time"] = DateTime.Now;
     //直接保存
     e.Cancel = false;
 }
示例#31
0
        /// <summary>
        /// 根据输入的参数值来执行更新数据
        /// </summary>
        /// <param name="e">传入的带有数据的事件参数</param>
        /// <returns></returns>
        private bool UpdateData(FormViewUpdateEventArgs e)
        {
            //数据适配器
            //当前添加语句对象
            //当前数据库连接
            using (var da = new v_complete_lot_card_backTableAdapter())
            using (var conn = da.Connection)
            {
                //打开数据库连接
                conn.Open();
                //开启事务
                using (var tran = conn.BeginTransaction())
                {
                    //设置事务
                    da.Transaction = tran;
                    //试运行
                    try
                    {
                        //部门名称
                        string procName = e.OldValues["proc_name"].ToString();
                        //当前行单号
                        string billNum = Convert.ToString(e.Keys[0]);
                        //获取数据
                        using (var tab = da.GetDataByBillNum(billNum))
                        {
                            //检查是否获取到行
                            if (tab.Rows.Count == 0)
                            {
                                //显示失败
                                throw new Exception("当前记录已经被其他用户删除!");
                            }
                            //数据适配器
                            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())
                            {
                                //设置数据库连接
                                daHead.Connection = daContent.Connection = daBalance.Connection = conn;
                                //设置事务
                                daHead.Transaction = daContent.Transaction = daBalance.Transaction = tran;
                                //将之前的单据内容写回
                                foreach (DataSetCompleteBack.v_complete_lot_card_backRow row in tab.Rows)
                                {
                                    //从成品结存清单中扣除
                                    if (!ydOperateCompleteLotCard.DecreaseCompleteBalance(
                                        daBalance,
                                        row.prev_proc_name,
                                        row.lot_id,
                                        row.pnl_qty,
                                        row.pcs_qty
                                    ))
                                    {
                                        return false;
                                    }
                                }
                                //从单据内容中删除
                                daContent.DeleteByBillNum(billNum);
                                //从单据表头中删除
                                daHead.Delete(billNum);

                                //日期
                                DateTime billDate = Convert.ToDateTime(e.NewValues["bill_date"]);
                                //单据备注
                                string billRemark = Convert.ToString(e.NewValues["remark"]);
                                //录入员
                                string addPerson = e.NewValues["add_person"].ToString();
                                //录入时间
                                DateTime addTime = Convert.ToDateTime(e.NewValues["add_time"]);
                                //最后修改时间
                                DateTime lastChangeTime = Convert.ToDateTime(e.NewValues["last_change_time"]);
                                //保存表头
                                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 UserFormView_ItemUpdating(object sender, FormViewUpdateEventArgs e)
        {
            FormView userFormView = sender as FormView;
            if (UserFormView != null)
            {
                DropDownList departmentDropDownList =
                    userFormView.FindControl("DepartmentDropDownList") as DropDownList;
                e.NewValues["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.NewValues["Role"] = roles;
            }
        }