protected void fvMaterialSupplierAdd_ItemDeleting(object sender, FormViewDeleteEventArgs 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("您没有删除记录权限!");
     }
     //当前供应商代码
     string code = Convert.ToString(e.Keys[0]);
     //根据id执行删除数据
     if (DeleteData(e))
     {
         //调用过程执行跳转
         JumpToUrlByCode(code);
     }
 }
 protected void FormView1_ItemDeleting(object sender, FormViewDeleteEventArgs e)
 {
     Label lblId = FormView1.FindControl("ViewId") as Label;
     var longId = long.Parse(lblId.Text);
     var elements = from element in _dataContext.MedicalServices
                    where element.medicalServiceGroupId == longId
                    select element;
     if (elements.Count() != 0)
     {
         var medicalServicesArray = elements.ToArray();
         for (var i = 0; i < medicalServicesArray.Count(); i++)
         {
             var labOrderDetails = from element in _dataContext.LabOrderDetails
                                   where medicalServicesArray[i].medicalServiceId == element.medicalServiceId
                                   select element;
             if (labOrderDetails.Count() != 0)
             {
                 _dataContext.LabOrderDetails.DeleteAllOnSubmit(labOrderDetails);
             }
         }
         _dataContext.MedicalServices.DeleteAllOnSubmit(elements);
         _dataContext.SubmitChanges();
         return;
     }
 }
        /**
         * We are in "default mode" mode, and the "delete" button was pressed
         * */
        protected void PGFV_ItemDeleting(Object sender, FormViewDeleteEventArgs e)
        {
            String id = ((TextBox)this.PGFV.FindControl("albumIdTextBox")).Text;
            controller.removeAlbum(Int32.Parse(id));

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

            //Change the form view mode
            this.PGFV.ChangeMode(FormViewMode.ReadOnly);
            rebindForm(-1); rebindForm(-1);
            //Response.Write("Deleting");
        }
Esempio n. 4
0
        /**
         * We are in "default mode" mode, and the "delete" button was pressed
         * */
        protected void EventEditorFormView_ItemDeleting(Object sender, FormViewDeleteEventArgs e)
        {
            String id = ((TextBox)EventEditorFormView.FindControl("idTextBox")).Text;
            controller.removeEVent(Int32.Parse(id));

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

            //Change the form view mode
            EventEditorFormView.ChangeMode(FormViewMode.ReadOnly);
            rebindForm(-1); rebindForm(-1);
            //Response.Write("Deleting");
        }
 //ItemDeleting Event Control
 protected void FormView1_ItemDeleting(object sender, FormViewDeleteEventArgs e)
 {
     Label lblId = FormView1.FindControl("ViewId") as Label;
     var id = long.Parse(lblId.Text);
     var elements = from element in _dataContext.PrescriptionDetails
                    where element.drugId == id
                    select element;
     if (elements.Count() != 0)
     {
         _dataContext.PrescriptionDetails.DeleteAllOnSubmit(elements);
         _dataContext.SubmitChanges();
         return;
     }
 }
        //ItemDeleting Event Control
        protected void FormView1_ItemDeleting(object sender, FormViewDeleteEventArgs e)
        {
            Label lblId = FormView1.FindControl("ViewId") as Label;
            var intId = long.Parse(lblId.Text);
            var labOrders = from element in _dataContext.LabOrders
                            where element.doctorId == intId
                            select element;
            var prescriptions = from element in _dataContext.Prescriptions
                                where element.doctorId == intId
                                select element;
            var visits = from element in _dataContext.Visits
                         where element.doctorId == intId
                         select element;

            if (labOrders.Count() != 0)
            {
                var labOrderArray = labOrders.ToArray();
                for (var i = 0; i < labOrderArray.Count(); i++)
                {
                    var labOrderDetail = from element in _dataContext.LabOrderDetails
                                         where element.labOrderId == labOrderArray[i].labOrderId
                                         select element;
                    if (labOrderDetail.Count() != 0)
                    {
                        _dataContext.LabOrderDetails.DeleteAllOnSubmit(labOrderDetail);
                    }
                }
                _dataContext.LabOrders.DeleteAllOnSubmit(labOrders);
            }
            else if (prescriptions.Count() != 0)
            {
                var prescriptArray = prescriptions.ToArray();
                for (var i = 0; i < prescriptArray.Count(); i++)
                {
                    var prescriptionDetail = from element in _dataContext.PrescriptionDetails
                                             where element.prescriptionId == prescriptArray[i].prescriptionId
                                             select element;
                    if (prescriptionDetail.Count() != 0)
                    {
                        _dataContext.PrescriptionDetails.DeleteAllOnSubmit(prescriptionDetail);
                    }
                }
                _dataContext.Prescriptions.DeleteAllOnSubmit(prescriptions);
            }
            else if (visits.Count() != 0)
            {
                _dataContext.Visits.DeleteAllOnSubmit(visits);
            }
            _dataContext.SubmitChanges();
        }
        protected void FormView1_ItemDeleting(object sender, FormViewDeleteEventArgs e)
        {
            Label lbl = HospitalFormView.FindControl("ViewId") as Label;
            var hospitalId = long.Parse(lbl.Text);
            var elements = from element in _dataContext.Visits
                           where element.hospitalId == hospitalId
                           select element;

            if (elements.Count() != 0)
            {
                _dataContext.Visits.DeleteAllOnSubmit(elements);
                _dataContext.SubmitChanges();
                return;
            }
        }
Esempio n. 8
0
        protected void formFeeds_ItemDeleting(object sender, FormViewDeleteEventArgs e)
        {
            String name = ((Label)formFeeds.Row.Cells[0].FindControl("nameFeed")).Text;
            String url = ((Label)formFeeds.Row.Cells[0].FindControl("urlFeed")).Text;
            XmlDocument xdoc = XmlDataSource_feed.GetXmlDocument();

            XmlElement feeds = xdoc.SelectSingleNode("feeds") as XmlElement;
            XmlElement feed = xdoc.SelectSingleNode("feeds/feed[@name='" + name + "'][@url = '" + url + "']") as XmlElement;
            feeds.RemoveChild(feed);

            XmlDataSource_feed.Save();

            e.Cancel = true;

            formFeeds.DataBind();
        }
        //ItemDeleting Event Control
        protected void FormView1_ItemDeleting(object sender, FormViewDeleteEventArgs e)
        {
            Label lblId = FormView1.FindControl("ViewId") as Label;
            var id = long.Parse(lblId.Text);
            var labOrderDetails = from element in _dataContext.LabOrderDetails
                                  where element.labOrderId == id
                                  select element;
            var visits = from element in _dataContext.Visits
                         where element.labOrderId == id
                         select element;

            if (labOrderDetails.Count() != 0)
            {
                _dataContext.LabOrderDetails.DeleteAllOnSubmit(labOrderDetails);
            }
            else if (visits.Count() != 0)
            {
                _dataContext.Visits.DeleteAllOnSubmit(visits);
            }
            _dataContext.SubmitChanges();
        }
Esempio n. 10
0
        // FormView.ItemDeleting 事件
        protected void fvPerson_ItemDeleting(object sender, FormViewDeleteEventArgs e)
        {
            // 从Web.config获取链接字符串.
            // 当我们使用Using语句时,
            // 不需要显式释放代码中的对象,
            // using语句会处理他们.
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLServer2005DBConnectionString"].ToString()))
            {
                // 新建一个命令对象.
                SqlCommand cmd = new SqlCommand();

                // 将数据链接关联到命令.
                cmd.Connection = conn;

                // 设定命令文本
                // SQL语句或者存储过程名字.
                cmd.CommandText = "DELETE FROM Person WHERE PersonID = @PersonID";

                // 设定命令类型
                // CommandType.Text 表示原始SQL语句;
                // CommandType.StoredProcedure 表示存储过程.
                cmd.CommandType = CommandType.Text;

                // 从FormView控件的ItemTemplate中获取PersonID.
                //
                string strPersonID = ((Label)fvPerson.Row.FindControl("lblPersonID")).Text;

                // 向SqlCommand添加参数并设值.
                cmd.Parameters.Add("@PersonID", SqlDbType.Int).Value = strPersonID;

                // 打开数据链接.
                conn.Open();

                // 执行命令.
                cmd.ExecuteNonQuery();
            }

            // 重新绑定FormView控件以显示删除后的数据.
            BindFormView();
        }
 protected void FormView1_ItemDeleting(object sender, FormViewDeleteEventArgs e)
 {
     Label lblId = FormView1.FindControl("ViewId") as Label;
     var longId = long.Parse(lblId.Text);
     var elements = from element in _dataContext.Icds
                    where element.icdChapterId == longId
                    select element;
     if (elements.Count() != 0)
     {
         var icdChapterArray = elements.ToArray();
         for (var i = 0; i < icdChapterArray.Count(); i++)
         {
             var visit = from element in _dataContext.Visits
                         where element.icdId == icdChapterArray[i].icdId
                         select element;
             if (visit.Count() != 0)
             {
                 _dataContext.Visits.DeleteAllOnSubmit(visit);
             }
         }
         _dataContext.Icds.DeleteAllOnSubmit(elements);
         _dataContext.SubmitChanges();
     }
 }
 protected void FormView1_ItemDeleting(object sender, FormViewDeleteEventArgs e)
 {
     Label lblId = FormView1.FindControl("ViewId") as Label;
     var longId = long.Parse(lblId.Text);
     var elements = from element in _dataContext.Drugs
                    where element.drugGroupId == longId
                    select element;
     if (elements.Count() != 0)
     {
         var drugArray = elements.ToArray();
         for (var i = 0; i < drugArray.Count(); i++)
         {
             var prescriptionDetail = from element in _dataContext.PrescriptionDetails
                                      where element.drugId == drugArray[i].drugId
                                      select element;
             if (prescriptionDetail.Count() != 0)
             {
                 _dataContext.PrescriptionDetails.DeleteAllOnSubmit(prescriptionDetail);
             }
         }
         _dataContext.Drugs.DeleteAllOnSubmit(elements);
         _dataContext.SubmitChanges();
     }
 }
Esempio n. 13
0
 /// <summary>
 /// 执行删除数据并处理相关数据一致性
 /// </summary>
 /// <param name="e">传入的带有数据的事件参数</param>
 /// <returns></returns>
 private bool DeleteData(FormViewDeleteEventArgs e)
 {
     //当前用户输入的id号
     Int64 id = Convert.ToInt64(e.Keys[0]);
     //数据适配器
     //当前数据库连接
     //当前更新语句对象
     using (var da = new t_product_record_wenziTableAdapter())
     using (var cmd = da.Adapter.DeleteCommand)
     using (var conn = cmd.Connection)
     {
         //打开数据库连接
         conn.Open();
         //开启事务
         using (var tran = conn.BeginTransaction())
         {
             //试运行
             try
             {
                 //设置事务
                 da.Transaction = tran;
                 //获取数据
                 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 procName = row.proc_name;
                         //目标数据库表名
                         string toTabName = "[t_proc_lot_card_balance]";
                         //添加到部门结存批量卡
                         if (!ydOperateBalanceLotCrad.InsertOneRecordToLotCardBalance(
                             tran,
                             ydOperateBalanceLotCrad.GetTabNameByProcName(procName),
                             procName,
                             toTabName,
                             id,
                             true
                         ))
                         {
                             return false;
                         }
                         //从生产记录删除数据
                         if (!ydOperateBalanceLotCrad.DeleteOneRecordFromProductOrScrapRecord(cmd, id))
                         {
                             return false;
                         }
                     }
                 }
                 //提交事务
                 tran.Commit();
                 //返回成功
                 return true;
             }
             catch (Exception ex)
             {
                 //回滚事务
                 tran.Rollback();
                 //非数字返回失败
                 throw new Exception(ex.Message);
             }
         }
     }
 }
Esempio n. 14
0
 protected void fvProcLotCardMgrAdd_ItemDeleting(object sender, FormViewDeleteEventArgs 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("您没有删除记录权限!");
     }
     //当前id号
     Int64 id = Convert.ToInt64(e.Keys[0]);
     //执行删除数据
     if (DeleteData(id))
     {
         //调用过程执行跳转
         JumpToUrlById(id);
     }
 }
 protected virtual new void OnItemDeleting(FormViewDeleteEventArgs e)
 {
 }
Esempio n. 16
0
 protected void fvSampleLotCardMgrAdd_ItemDeleting(object sender, FormViewDeleteEventArgs 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("您没有删除记录权限!");
     }
     //执行删除方法
     if (ydOperateSampleLotCard.DeleteSampleLotCardRecordById(Convert.ToInt64(e.Keys["id"])))
     {
         //重新绑定数据
         fvSampleLotCardMgrAdd.DataBind();
     }
 }
Esempio n. 17
0
 /// <summary>
 /// 执行删除数据并处理相关数据一致性
 /// </summary>
 /// <param name="e">传入的带有数据的事件参数</param>
 /// <returns></returns>
 private bool DeleteData(FormViewDeleteEventArgs e)
 {
     //当前用户输入的id号
     Int64 id = Convert.ToInt64(e.Keys[0]);
     //数据适配器
     //当前数据库连接
     //当前更新语句对象
     using (var da = new t_use_waterTableAdapter())
     using (var cmd = da.Adapter.DeleteCommand)
     using (var conn = cmd.Connection)
     {
         //打开数据库连接
         conn.Open();
         //开启事务
         using (var tran = conn.BeginTransaction())
         {
             //试运行
             try
             {
                 //设置事务
                 da.Transaction = tran;
                 //获取数据
                 using (var tab = da.GetDataById(id))
                 {
                     //检查是否获取到行
                     if (tab.Rows.Count == 0)
                     {
                         //显示失败
                         throw new Exception("当前生产记录已经被其他用户删除!");
                     }
                     else
                     {
                         da.Delete(id);
                     }
                 }
                 //提交事务
                 tran.Commit();
                 //返回成功
                 return true;
             }
             catch (Exception ex)
             {
                 //回滚事务
                 tran.Rollback();
                 //非数字返回失败
                 throw new Exception(ex.Message);
             }
         }
     }
 }
Esempio n. 18
0
 protected void fvUseWaterAdd_ItemDeleting(object sender, FormViewDeleteEventArgs e)
 {
     //取消请求执行自定义的方法
     e.Cancel = true;
     if (!HasRight())
     {
         throw new Exception("您没有删除记录权限!");
     }
     //当前id号
     Int64 id = Convert.ToInt64(e.Keys[0]);
     //根据id执行删除数据
     if (DeleteData(e))
     {
         //调用过程执行跳转
         JumpToUrlById(id);
     }
 }
 protected void fvDeliveryBillMgrAdd_ItemDeleting(object sender, FormViewDeleteEventArgs 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 != 1 && roleId != 6))
     {
         throw new Exception("您没有删除记录权限!");
     }
     //执行删除的同时也删除单据的内容
     if (DeleteBillByBillNum(e.Keys[0].ToString()))
     {
         //待跳转到的url地址
         string strUrl = "./SampleDeliveryBillMgrAdd.aspx?oper=view&bnum=0";
         //直接跳转
         Response.Redirect(strUrl);
         //停止加载后续内容
         Response.End();
     }
 }
Esempio n. 20
0
 protected void fvEngLotCardAdd_ItemDeleting(object sender, FormViewDeleteEventArgs e)
 {
     //取消请求执行自定义的方法
     e.Cancel = true;
     if (!HasRight())
     {
         throw new Exception("您没有删除记录权限!");
     }
     //执行删除
     e.Cancel = false;
 }
        //ItemDeleting Event Control
        protected void FormView1_ItemDeleting(object sender, FormViewDeleteEventArgs e)
        {
            Label lblId = FormView1.FindControl("ViewId") as Label;
            var intId = long.Parse(lblId.Text);
            var visit = from element in _dataContext.Visits
                        where element.patientId == intId
                        select element;

            if (visit.Count() != 0)
            {
                _dataContext.Visits.DeleteAllOnSubmit(visit);
                _dataContext.SubmitChanges();
                return;
            }
        }
Esempio n. 22
0
 protected void fvCompleteBackAdd_ItemDeleting(object sender, FormViewDeleteEventArgs 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("您没有删除记录权限!");
     }
     //当前单号
     string billNum = Convert.ToString(e.Keys[0]);
     //根据单号执行删除数据
     if (DeleteData(e))
     {
         //调用过程执行跳转
         JumpToUrlByBillNum(billNum);
     }
 }
			public void DoOnItemDeleting (FormViewDeleteEventArgs e)
			{
				OnItemDeleting (e); 
			}
Esempio n. 24
0
 /// <summary>
 /// 执行删除数据并处理相关数据一致性
 /// </summary>
 /// <param name="e">传入的带有数据的事件参数</param>
 /// <returns></returns>
 private bool DeleteData(FormViewDeleteEventArgs e)
 {
     //当前供应商代码
     string code = Convert.ToString(e.Keys[0]);
     //数据适配器
     //当前数据库连接
     //当前更新语句对象
     using (var da = new t_material_supplierTableAdapter())
     {
         //试运行
         try
         {
             //执行删除
             da.Delete(code);
             //返回成功
             return true;
         }
         catch (Exception ex)
         {
             //非数字返回失败
             throw new Exception(ex.Message);
         }
     }
 }
		private void fv_ItemDeleting (object sender, FormViewDeleteEventArgs e)
		{
			itemDeleting = true;
		}
		static void d_ItemDeleting (object sender, FormViewDeleteEventArgs e)
		{
			if (WebTest.CurrentTest.UserData == null) {
				ArrayList list = new ArrayList ();
				list.Add ("ItemDeleting");
				WebTest.CurrentTest.UserData = list;
			}
			else {
				ArrayList list = WebTest.CurrentTest.UserData as ArrayList;
				if (list == null)
					throw new NullReferenceException ();
				list.Add ("ItemDeleting");
				WebTest.CurrentTest.UserData = list;
			}
		}
Esempio n. 27
0
 /// <summary>
 /// 在ViewState中保持行索引用来Item_Deleted.
 /// </summary>
 protected void fvPersonDetails_ItemDeleting(object sender, FormViewDeleteEventArgs e)
 {
     ViewState["delindex"] = gvPersonOverView.SelectedIndex;
 }
		public void fv_DeleteingHandler (Object sender, FormViewDeleteEventArgs e)
		{
			isDeleted = true;
		}
Esempio n. 29
0
 /// <summary>
 /// 执行删除数据并处理相关数据一致性
 /// </summary>
 /// <param name="e">传入的带有数据的事件参数</param>
 /// <returns></returns>
 private bool DeleteData(FormViewDeleteEventArgs e)
 {
     //当前单号
     string billNum = Convert.ToString(e.Keys[0]);
     //数据适配器
     //当前数据库连接
     //当前更新语句对象
     using (var da = new v_material_outTableAdapter())
     using (var conn = da.Connection)
     {
         //打开数据库连接
         conn.Open();
         //开启事务
         using (var tran = conn.BeginTransaction())
         {
             //试运行
             try
             {
                 //设置事务
                 da.Transaction = tran;
                 //获取数据
                 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("删除单据表头记录失败!");
                     }
                 }
                 //提交事务
                 tran.Commit();
                 //返回成功
                 return true;
             }
             catch (Exception ex)
             {
                 //回滚事务
                 tran.Rollback();
                 //非数字返回失败
                 throw new Exception(ex.Message);
             }
         }
     }
 }
Esempio n. 30
0
 /// <summary>
 /// 执行删除数据并处理相关数据一致性
 /// </summary>
 /// <param name="e">传入的带有数据的事件参数</param>
 /// <returns></returns>
 private bool DeleteData(FormViewDeleteEventArgs e)
 {
     //当前单号
     string billNum = Convert.ToString(e.Keys[0]);
     //数据适配器
     //当前数据库连接
     //当前更新语句对象
     using (var da = new v_complete_lot_card_backTableAdapter())
     using (var conn = da.Connection)
     {
         //打开数据库连接
         conn.Open();
         //开启事务
         using (var tran = conn.BeginTransaction())
         {
             //试运行
             try
             {
                 //设置事务
                 da.Transaction = tran;
                 //获取数据
                 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);
                 }
                 //提交事务
                 tran.Commit();
                 //返回成功
                 return true;
             }
             catch (Exception ex)
             {
                 //回滚事务
                 tran.Rollback();
                 //非数字返回失败
                 throw new Exception(ex.Message);
             }
         }
     }
 }
Esempio n. 31
0
 protected void fvScrapCodeAdd_ItemDeleting(object sender, FormViewDeleteEventArgs 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.Cancel = false;
 }