Example #1
0
        public void CommitEvent(object key)
        {
            BudConModifyService    service  = new BudConModifyService();
            BudContractTaskService service2 = new BudContractTaskService();
            BudConModify           byId     = service.GetById(key.ToString());

            service2.DeleteYearMonthByPrj(byId.PrjId);
            IList <cn.justwin.Domain.Entities.BudContractTask> byProject = service2.GetByProject(byId.PrjId, 0x3e7);
            IList <int> years = service2.GetYears(byId.PrjId);

            if (years != null)
            {
                foreach (int num in years)
                {
                    IList <cn.justwin.Domain.Entities.BudContractTask> yearTask = service2.GetYearTask(byProject, num);
                    foreach (cn.justwin.Domain.Entities.BudContractTask task in yearTask)
                    {
                        service2.Add(task);
                    }
                    foreach (int num2 in service2.GetMonths(yearTask, num))
                    {
                        foreach (cn.justwin.Domain.Entities.BudContractTask task2 in service2.GetMonthTasks(yearTask, num, num2))
                        {
                            service2.Add(task2);
                        }
                    }
                }
            }
        }
Example #2
0
    protected void btnDel_Click(object sender, EventArgs e)
    {
        BudConModifyService     budConModifyService     = new BudConModifyService();
        BudConModifyTaskService budConModifyTaskService = new BudConModifyTaskService();
        BudContractTaskService  budContractTaskService  = new BudContractTaskService();
        List <string>           list = new List <string>();

        using (SqlConnection sqlConnection = new SqlConnection(SqlHelper.ConnectionString))
        {
            sqlConnection.Open();
            SqlTransaction sqlTransaction = sqlConnection.BeginTransaction();
            try
            {
                foreach (GridViewRow gridViewRow in this.gvConract.Rows)
                {
                    CheckBox checkBox = gridViewRow.FindControl("cbBox") as CheckBox;
                    if (checkBox != null && checkBox.Checked)
                    {
                        int num = this.incometModifyBll.Delete(sqlTransaction, checkBox.ToolTip);
                        if (num > 0)
                        {
                            BudConModify budConModify = budConModifyService.GetByConInModifyID(checkBox.ToolTip);
                            if (budConModify != null)
                            {
                                this.DeleteInModifyTaskAndMeasure(budConModify.ModifyId);
                                List <string> list2 = (
                                    from r in budConModifyTaskService
                                    where r.ModifyId == budConModify.ModifyId
                                    select r.TaskId).ToList <string>();
                                foreach (string taskId in list2)
                                {
                                    BudContractTask budContractTask = (
                                        from r in budContractTaskService
                                        where r.TaskId == taskId
                                        select r).FirstOrDefault <BudContractTask>();
                                    BudConModifyTask budConModifyTask = (
                                        from r in budConModifyTaskService
                                        where r.TaskId == taskId && r.ModifyId == budConModify.ModifyId
                                        select r).FirstOrDefault <BudConModifyTask>();
                                    if (budContractTask != null)
                                    {
                                        if (budContractTask.ModifyType == "0")
                                        {
                                            budContractTaskService.Delete(budContractTask);
                                        }
                                        else
                                        {
                                            budContractTask.EndDate     = budConModifyTask.EndDate;
                                            budContractTask.StartDate   = budConModifyTask.StartDate;
                                            budContractTask.TaskCode    = budConModifyTask.ModifyTaskCode;
                                            budContractTask.TaskName    = budConModifyTask.ModifyTaskContent;
                                            budContractTask.Unit        = budConModifyTask.Unit;
                                            budContractTask.Total       = new decimal?(Convert.ToDecimal(budContractTask.Total) - budConModifyTask.Total);
                                            budContractTask.InputDate   = DateTime.Now;
                                            budContractTask.IsValid     = new bool?(false);
                                            budContractTask.Note        = budConModifyTask.Note;
                                            budContractTask.OrderNumber = budConModifyTask.OrderNumber;
                                            budContractTask.ParentId    = budConModifyTask.ParentId;
                                            budContractTask.PrjId       = budConModifyTask.PrjId2;
                                            budContractTask.Quantity    = Convert.ToDecimal(budContractTask.Quantity) - budConModifyTask.Quantity;
                                            budContractTask.TaskId      = budConModifyTask.TaskId;
                                            budContractTask.ModifyId    = null;
                                            budContractTask.ModifyType  = "1";
                                            if (budContractTask.Quantity != 0m)
                                            {
                                                budContractTask.UnitPrice = budContractTask.Total / budContractTask.Quantity;
                                            }
                                            budContractTask.TaskType           = string.Empty;
                                            budContractTask.InputUser          = PageHelper.QueryUser(this, base.UserCode);
                                            budContractTask.FeatureDescription = budConModifyTask.FeatureDescription;
                                            budContractTask.ConstructionPeriod = budConModifyTask.ConstructionPeriod;
                                            budContractTask.MainMaterial       = new decimal?(Convert.ToDecimal(budContractTask.MainMaterial) - Convert.ToDecimal(budConModifyTask.MainMaterial));
                                            budContractTask.Labor       = new decimal?(Convert.ToDecimal(budContractTask.Labor) - Convert.ToDecimal(budConModifyTask.Labor));
                                            budContractTask.SubMaterial = new decimal?(Convert.ToDecimal(budContractTask.SubMaterial) - Convert.ToDecimal(budConModifyTask.SubMaterial));
                                            budContractTaskService.Update(budContractTask);
                                        }
                                    }
                                }
                                budConModifyTaskService.DelModifyTask(budConModify.ModifyId);
                                list.Add(budConModify.ModifyId);
                                budConModifyService.Delete(list);
                            }
                            base.RegisterScript("top.ui.show('数据删除成功!');");
                            base.RegisterScript("window.location = window.location");
                        }
                    }
                }
                sqlTransaction.Commit();
                this.BindGv();
            }
            catch (Exception)
            {
                sqlTransaction.Rollback();
                base.RegisterScript("alert('系统提示:\\n\\n对不起添加失败!');");
            }
        }
    }