Example #1
0
    protected void btnDel_Click(object sender, System.EventArgs e)
    {
        ConIncometContractService conIncometContractService = new ConIncometContractService();
        BudContractTaskService    budContractTaskService    = new BudContractTaskService();

        using (SqlConnection sqlConnection = new SqlConnection(SqlHelper.ConnectionString))
        {
            sqlConnection.Open();
            SqlTransaction sqlTransaction = sqlConnection.BeginTransaction();
            try
            {
                string message = "";
                System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>();
                foreach (GridViewRow gridViewRow in this.gvConract.Rows)
                {
                    CheckBox checkBox = gridViewRow.FindControl("cbBox") as CheckBox;
                    if (checkBox != null && checkBox.Checked)
                    {
                        if (!this.incometContractBll.IsDel(checkBox.ToolTip))
                        {
                            list.Clear();
                            message = "alert('系统提示:\\n\\n请先删除与收款合同相关的其他数据!')";
                            break;
                        }
                        ConIncometContract byContractId = conIncometContractService.GetByContractId(checkBox.ToolTip);
                        budContractTaskService.DelRalationBudgetAndContract(byContractId.Project, checkBox.ToolTip);
                        this.rptSev.DelByContractId(checkBox.ToolTip);
                        list.Add(checkBox.ToolTip);
                        message = "alert('系统提示:\\n\\n数据删除成功!');location='IncometContractList.aspx'";
                    }
                }
                Common2.DelByStrWhere("Con_Incomet_Contract", " where ContractId in (" + StringUtility.GetArrayToInStr(list.ToArray()) + ")");
                ConConfigContractService conConfigContractService = new ConConfigContractService();
                conConfigContractService.Deltes(list);
                base.RegisterScript(message);
                sqlTransaction.Commit();
                this.BindGv();
            }
            catch (System.Exception)
            {
                sqlTransaction.Rollback();
                base.RegisterScript("alert('系统提示:\\n\\n对不起删除失败!');");
            }
        }
    }
Example #2
0
 protected void btnDelete_Click(object sender, System.EventArgs e)
 {
     System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>();
     if (this.hfldContract.Value.Contains("["))
     {
         list = JsonHelper.GetListFromJson(this.hfldContract.Value);
     }
     else
     {
         list.Add(this.hfldContract.Value);
     }
     try
     {
         foreach (string current in list)
         {
             System.Collections.Generic.List <PayoutContractModel> list2 = this.payoutContract.GetList(string.Format(" Con_Payout_Contract.MainContractID = '{0}'", current));
             if (list2.Count > 0)
             {
                 base.RegisterScript("top.ui.alert('请先删除补充协议!');");
                 return;
             }
             if (this.payoutContract.IsReferenced(current))
             {
                 base.RegisterScript("top.ui.alert('请先删除此合同的关联数据!');");
                 return;
             }
         }
         PayoutTarget payoutTarget = new PayoutTarget();
         payoutTarget.DelByContractId(list);
         this.payoutContract.Delete(list);
         ConConfigContractService conConfigContractService = new ConConfigContractService();
         conConfigContractService.Deltes(list);
         base.RegisterScript("window.location = window.location;");
     }
     catch
     {
         base.RegisterScript("top.ui.alert('删除失败!');");
     }
 }