Пример #1
0
    protected void btnSave_Click(object sender, System.EventArgs e)
    {
        string  text   = this.txtQuantity.Text;
        string  value  = this.txtUnitPrice.Text.Trim();
        decimal value2 = System.Convert.ToDecimal(text) * System.Convert.ToDecimal(value);

        if (string.IsNullOrEmpty(text))
        {
            base.RegisterScript("top.ui.alert('工程量必须输入');");
            this.txtQuantity.Focus();
            return;
        }
        if (string.IsNullOrEmpty(value))
        {
            base.RegisterScript("top.ui.alert('综合单价必须输入');");
            this.txtUnitPrice.Focus();
            return;
        }
        string taskCode = this.txtTaskCode.Text.Trim();
        bool   flag     = false;

        if (this.ViewState["oldCode"] != null)
        {
            this.ViewState["oldCode"].ToString();
        }
        else
        {
            string arg_B0_0 = string.Empty;
        }
        if (flag)
        {
            base.RegisterScript("top.ui.alert('清单编码不能重复');");
            this.txtTaskCode.Focus();
            return;
        }
        string taskName = this.txtTaskName.Text.Trim();

        System.DateTime?startDate = null;
        if (!string.IsNullOrEmpty(this.txtStartDate.Text))
        {
            startDate = new System.DateTime?(System.Convert.ToDateTime(this.txtStartDate.Text));
        }
        System.DateTime?endDate = null;
        if (!string.IsNullOrEmpty(this.txtEndDate.Text))
        {
            endDate = new System.DateTime?(System.Convert.ToDateTime(this.txtEndDate.Text));
        }
        string unit               = this.txtUnit.Text.Trim();
        string arg_15D_0          = this.ddlTaskType.SelectedValue;
        string note               = this.txtNote.Text.Trim();
        int?   constructionPeriod = null;

        if (!string.IsNullOrEmpty(this.txtConstructionPeriod.Text.Trim()))
        {
            constructionPeriod = new int?(System.Convert.ToInt32(this.txtConstructionPeriod.Text.Trim()));
        }
        string arg_1B6_0 = this.txtConstructionPeriod.Text;
        BudContractTaskService budContractTaskService = new BudContractTaskService();

        cn.justwin.Domain.Entities.BudContractTask budContractTask;
        if (this.type.ToUpper() == "EDIT")
        {
            budContractTask = budContractTaskService.GetById(this.id);
        }
        else
        {
            budContractTask             = new cn.justwin.Domain.Entities.BudContractTask();
            budContractTask.TaskId      = System.Guid.NewGuid().ToString();
            budContractTask.OrderNumber = cn.justwin.Domain.BudContractTask.GetOrderNumber(this.prjId, this.id);
            if (string.IsNullOrEmpty(this.id))
            {
                budContractTask.ParentId = null;
            }
            else
            {
                budContractTask.ParentId = this.id;
            }
            budContractTask.PrjId     = this.prjId;
            budContractTask.InputUser = base.UserCode;
            budContractTask.InputDate = System.DateTime.Now;
        }
        budContractTask.TaskCode           = taskCode;
        budContractTask.TaskName           = taskName;
        budContractTask.Unit               = unit;
        budContractTask.Quantity           = System.Convert.ToDecimal(text);
        budContractTask.StartDate          = startDate;
        budContractTask.EndDate            = endDate;
        budContractTask.ConstructionPeriod = constructionPeriod;
        budContractTask.Note               = note;
        budContractTask.UnitPrice          = new decimal?(System.Convert.ToDecimal(value));
        budContractTask.Total              = new decimal?(value2);
        budContractTask.TaskType           = "";
        budContractTask.FeatureDescription = this.txtDescription.Text.Trim();
        budContractTask.MainMaterial       = new decimal?(System.Convert.ToDecimal(this.txtMainMaterial.Text.Trim()));
        budContractTask.SubMaterial        = new decimal?(System.Convert.ToDecimal(this.txtSubMaterial.Text.Trim()));
        budContractTask.Labor              = new decimal?(System.Convert.ToDecimal(this.txtLabor.Text.Trim()));
        if (this.type.ToUpper() == "EDIT")
        {
            budContractTaskService.Update(budContractTask);
        }
        else
        {
            budContractTaskService.Add(budContractTask);
        }
        string str  = "resetData();";
        string str2 = "top.ui.winSuccess({parentName:'_BudContractTaskTaskEdit'});";

        base.RegisterScript(str + str2);
    }
Пример #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对不起添加失败!');");
            }
        }
    }