Beispiel #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!base.IsPostBack)
     {
         DataTable dataTable = new DataTable();
         if (string.Compare(this.action, "Add", true) == 0)
         {
             this.InintAddState();
             this.modifyStockAction = "add";
             dataTable = this.purchaseStock.GetPurchaseStockByContractId(this.contractId, false);
             DataColumn dataColumn = new DataColumn("ModifyStockId", typeof(string));
             dataColumn.DefaultValue = string.Empty;
             dataTable.Columns.Add(dataColumn);
             this.hfldBudModifyId.Value = Guid.NewGuid().ToString();
         }
         else
         {
             this.InitUpdateState();
             this.modifyStockAction = "edit";
             dataTable = this.purchaseStock.GetModifyStockByContractId(this.contractId, this.modifyId);
             ConPayoutModifyService conPayoutModifyService = new ConPayoutModifyService();
             ConPayoutModify        byId = conPayoutModifyService.GetById(this.modifyId);
             if (byId != null && !string.IsNullOrEmpty(byId.BudModifyId))
             {
                 this.hfldBudModifyId.Value = byId.BudModifyId;
             }
             else
             {
                 this.hfldBudModifyId.Value = Guid.NewGuid().ToString();
             }
             this.InitBudTask();
         }
         this.ViewState["modifyStockAction"] = this.modifyStockAction;
         this.ViewState["resource"]          = dataTable;
         this.DataBindPurchaseplanStock();
         string conPurchasePcode = this.purchase.GetConPurchasePcode(this.contractId);
         if (string.IsNullOrEmpty(conPurchasePcode))
         {
             this.divPurchase.Style.Add("display", "none");
         }
         this.FileLink1.MID            = 1902;
         this.FileLink1.FID            = this.hfldModifyId.Value;
         this.FileLink1.Type           = 1;
         this.hfldIsWBSRelevance.Value = ConfigurationManager.AppSettings["IsWBSRelevance"];
         List <BudModifyTask> list = (
             from mt in this.modifyTaskSer
             where mt.ModifyId == this.hfldBudModifyId.Value
             select mt).ToList <BudModifyTask>();
         if (this.hfldIsWBSRelevance.Value == "1")
         {
             foreach (BudModifyTask current in list)
             {
                 this.BindModifyTaskRes(current.ModifyTaskId);
             }
         }
     }
 }
Beispiel #2
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (string.Compare(this.action, "Add", true) == 0)
     {
         this.AddContractModify();
         ConPayoutModifyService conPayoutModifyService = new ConPayoutModifyService();
         ConPayoutModify        byId = conPayoutModifyService.GetById(this.hfldModifyId.Value);
         byId.BudModifyId = this.hfldBudModifyId.Value;
         conPayoutModifyService.Update(byId);
     }
     else
     {
         if (string.Compare(this.action, "Update", true) == 0)
         {
             this.UpdateContractModify();
         }
     }
     this.UpdateModifyTask();
 }
Beispiel #3
0
        public void CommitEvent(object key)
        {
            BudModifyService       service  = new BudModifyService();
            BudTaskService         service2 = new BudTaskService();
            BudModifyTaskService   service3 = new BudModifyTaskService();
            BudTaskResourceService service4 = new BudTaskResourceService();
            ConPayoutModifyService service5 = new ConPayoutModifyService();
            string    modifyId  = key.ToString();
            BudModify budmodify = (from r in service
                                   where r.ModifyId == modifyId
                                   select r).FirstOrDefault <BudModify>();
            ConPayoutModify item = (from r in service5
                                    where r.BudModifyId == modifyId
                                    select r).FirstOrDefault <ConPayoutModify>();

            if (item != null)
            {
                item.FlowState = 1;
                service5.Update(item);
            }
            using (List <BudModifyTask> .Enumerator enumerator = (from p in service3
                                                                  where p.ModifyId == budmodify.ModifyId
                                                                  select p).ToList <BudModifyTask>().GetEnumerator())
            {
                BudModifyTask taskx;
                while (enumerator.MoveNext())
                {
                    taskx = enumerator.Current;
                    cn.justwin.Domain.Entities.BudTask task = (from p in service2
                                                               where p.TaskId == taskx.TaskId
                                                               select p).FirstOrDefault <cn.justwin.Domain.Entities.BudTask>();
                    if ((task != null) && (budmodify.Flowstate == 1))
                    {
                        if (taskx.ModifyType == 0)
                        {
                            task.IsValid = true;
                            service2.Update(task);
                            service3.UpdateTotal2(taskx.ModifyTaskId);
                        }
                        if ((task.ModifyId != task.ModifyId) || (taskx.ModifyType == 1))
                        {
                            task.ModifyId = task.ModifyId;
                            if (!task.Total2.HasValue)
                            {
                                task.Total2 = 0;
                            }
                            if (!task.Quantity.HasValue)
                            {
                                task.Quantity = 0;
                            }
                            task.Total2   = new decimal?(Convert.ToDecimal(task.Total2) + Convert.ToDecimal(task.Total2));
                            task.Quantity = new decimal?(Convert.ToDecimal(task.Quantity) + Convert.ToDecimal(task.Quantity));
                            if (task.Quantity != 0M)
                            {
                                task.UnitPrice = task.Total2 / task.Quantity;
                            }
                            service2.Update(task);
                            service3.UpdateTotal2(taskx.ModifyTaskId);
                        }
                    }
                }
            }
            if (ConfigHelper.Get("BudgetRequireDiff") != "0")
            {
                string    str2 = ConfigHelper.Get("IsWBSRelevance");
                BudModify byId = service.GetById(key.ToString());
                service2.DeleteYearMonthByPrj(byId.PrjId);
                IList <cn.justwin.Domain.Entities.BudTask> 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.BudTask> yearTask = service2.GetYearTask(byProject, num);
                        foreach (cn.justwin.Domain.Entities.BudTask task2 in yearTask)
                        {
                            service2.Add(task2);
                        }
                        foreach (int num2 in service2.GetMonths(yearTask, num))
                        {
                            foreach (cn.justwin.Domain.Entities.BudTask task3 in service2.GetMonthTasks(yearTask, num, num2))
                            {
                                service2.Add(task3);
                            }
                        }
                    }
                    if (str2 == "1")
                    {
                        service4.AddTaskResource(byId.PrjId);
                    }
                }
            }
        }
Beispiel #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!base.IsPostBack)
     {
         this.hfldIsWBSRelevance.Value = this.isWBSRelevance;
         List <BudModifyTask> list      = new List <BudModifyTask>();
         DataTable            dataTable = new DataTable();
         if (string.Compare(this.action, "Add", true) == 0)
         {
             this.InintAddState();
             this.modifyStockAction = "add";
             dataTable = this.purchaseStock.GetPurchaseStockByContractId(this.contractId, false);
             DataColumn dataColumn = new DataColumn("ModifyStockId", typeof(string));
             dataColumn.DefaultValue = string.Empty;
             dataTable.Columns.Add(dataColumn);
             this.hfldBudModifyId.Value = Guid.NewGuid().ToString();
         }
         else
         {
             this.InitUpdateState();
             this.modifyStockAction = "edit";
             dataTable = this.purchaseStock.GetModifyStockByContractId(this.contractId, this.modifyId);
             ConPayoutModifyService conPayoutModifyService = new ConPayoutModifyService();
             ConPayoutModify        byId = conPayoutModifyService.GetById(this.modifyId);
             if (byId != null && !string.IsNullOrEmpty(byId.BudModifyId))
             {
                 this.hfldBudModifyId.Value = byId.BudModifyId;
             }
             else
             {
                 this.hfldBudModifyId.Value = Guid.NewGuid().ToString();
             }
             this.hfldModifyId.Value = this.modifyId;
             list = (
                 from mt in this.modifyTaskSer
                 where mt.ModifyId == this.hfldBudModifyId.Value
                 select mt).ToList <BudModifyTask>();
             this.hfldAllModifyTaskJson.Value = JsonNetWrap.SerializeObject(list);
         }
         this.ViewState["modifyStockAction"] = this.modifyStockAction;
         this.ViewState["resource"]          = dataTable;
         this.DataBindPurchaseplanStock();
         string conPurchasePcode = this.purchase.GetConPurchasePcode(this.contractId);
         if (string.IsNullOrEmpty(conPurchasePcode))
         {
             this.divPurchase.Style.Add("display", "none");
         }
         this.FileLink1.MID  = 1902;
         this.FileLink1.FID  = this.hfldModifyId.Value;
         this.FileLink1.Type = 1;
         this.BindGv(list);
         if (this.hfldIsWBSRelevance.Value == "1")
         {
             using (List <BudModifyTask> .Enumerator enumerator = list.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     BudModifyTask current = enumerator.Current;
                     this.BindModifyTaskRes(current.ModifyTaskId);
                 }
                 return;
             }
         }
         base.Request.Cookies.Remove(this.hfldModifyId.Value);
         List <BudModifyTaskRes> t = (
             from mtss in this.modifyTaskResSer
             where mtss.ModifyId == this.hfldModifyId.Value
             select mtss).ToList <BudModifyTaskRes>();
         string     value      = JsonHelper.JsonSerializer <List <BudModifyTaskRes> >(t);
         HttpCookie httpCookie = new HttpCookie(this.hfldModifyId.Value);
         httpCookie.Value = value;
         base.Response.Cookies.Add(httpCookie);
     }
 }
Beispiel #5
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        int count = (
            from modify in this.modifySer
            where modify.PrjId == this.hdnProjectCode.Value.Trim() && modify.ModifyCode == this.txtModifyCode.Text.Trim()
            select modify).ToList <BudModify>().Count;

        if (string.Compare(this.action, "Add", true) == 0)
        {
            if (count > 0)
            {
                base.RegisterScript("top.ui.show('此编码已经存在!');");
                return;
            }
            this.AddContractModify();
            ConPayoutModifyService conPayoutModifyService = new ConPayoutModifyService();
            ConPayoutModify        byId = conPayoutModifyService.GetById(this.hfldModifyId.Value);
            byId.BudModifyId = this.hfldBudModifyId.Value;
            conPayoutModifyService.Update(byId);
            try
            {
                BudModify model = this.GetModel(null);
                this.modifySer.Add(model);
                this.SaveModifyTask();
                this.SaveTask();
                if (this.hfldIsWBSRelevance.Value == "0")
                {
                    this.SaveModifyTaskResByModifyId(this.hfldModifyId.Value);
                }
                base.RegisterScript("top.ui.tabSuccess({ parentName: 'ModifyEdit' });");
                return;
            }
            catch
            {
                base.RegisterScript("top.ui.show('添加失败!');");
                return;
            }
        }
        if (string.Compare(this.action, "Update", true) == 0)
        {
            this.UpdateContractModify();
            BudModify byId2 = this.modifySer.GetById(this.hfldBudModifyId.Value);
            if (byId2 != null && byId2.ModifyCode != this.txtModifyCode.Text.Trim() && count > 0)
            {
                base.RegisterScript("top.ui.show('此编码已经存在!');");
                return;
            }
            try
            {
                this.modifySer.Update(this.GetModel(byId2));
                this.modifyTaskSer.DelModifyTask(this.hfldBudModifyId.Value);
                this.SaveModifyTask();
                this.SaveTask();
                if (this.hfldIsWBSRelevance.Value == "0")
                {
                    this.SaveModifyTaskResByModifyId(this.hfldBudModifyId.Value);
                }
                base.RegisterScript("top.ui.tabSuccess({ parentName: 'ModifyEdit'});");
            }
            catch
            {
                base.RegisterScript("top.ui.show('编辑失败!');");
            }
        }
    }
Beispiel #6
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        List <string> listFromJson = JsonHelper.GetListFromJson(this.hfldModifyId.Value);

        foreach (string modifyId in listFromJson)
        {
            ConPayoutModify payOutModify = (
                from r in this.payOutSer
                where r.ModifyID == modifyId
                select r).FirstOrDefault <ConPayoutModify>();
            BudModify budModify = (
                from r in this.modifySer
                where r.ModifyId == payOutModify.BudModifyId
                select r).FirstOrDefault <BudModify>();
            if (budModify != null)
            {
                List <BudTask> list = (
                    from r in this.budTaskSer
                    where r.ModifyId == budModify.ModifyId
                    select r).ToList <BudTask>();
                foreach (BudTask model in list)
                {
                    BudModifyTask budModifyTask = (
                        from r in this.budModifyTaskSer
                        where r.TaskId == model.TaskId
                        select r).FirstOrDefault <BudModifyTask>();
                    if (budModifyTask.ModifyType == 0)
                    {
                        this.budTaskSer.Delete(model);
                        this.budModifyTaskSer.UpdateTotal2(budModifyTask.ModifyTaskId);
                        this.budModifyTaskSer.Delete(budModifyTask);
                    }
                    else
                    {
                        model.ModifyId  = budModifyTask.ModifyId;
                        model.Total2   -= budModifyTask.Total2;
                        model.Quantity -= budModifyTask.Quantity;
                        if (model.Quantity != 0m)
                        {
                            model.UnitPrice = model.Total2 / model.Quantity;
                        }
                        this.budTaskSer.Update(model);
                        this.budModifyTaskSer.UpdateTotal2(budModifyTask.ModifyTaskId);
                        this.budModifyTaskSer.Delete(budModifyTask);
                    }
                }
                this.modifySer.Delete(budModify);
            }
        }
        try
        {
            //foreach (string current in listFromJson)
            //{
            //	SelfEventAction.SuperDelete(current, "Con_Payout_Modify", "FlowState");
            //}
            this.payoutModify.Delete(listFromJson);
            base.RegisterScript("window.location = window.location;");
        }
        catch (Exception)
        {
            base.RegisterScript("alert('系统提示:\\n\\n删除失败!');");
        }
    }
Beispiel #7
0
        public void CommitEvent(object key)
        {
            string          primarykey   = key.ToString();
            ConPayoutModify payOutModify = (from r in this.payOutSer
                                            where r.ModifyID == primarykey
                                            select r).FirstOrDefault <ConPayoutModify>();
            BudModify budModify = (from r in this.modifySer
                                   where r.ModifyId == payOutModify.BudModifyId
                                   select r).FirstOrDefault <BudModify>();

            budModify.Flowstate = 1;
            this.modifySer.Update(budModify);
            using (List <BudModifyTask> .Enumerator enumerator = (from p in this.budModifyTaskSer
                                                                  where p.ModifyId == budModify.ModifyId
                                                                  select p).ToList <BudModifyTask>().GetEnumerator())
            {
                BudModifyTask task;
                while (enumerator.MoveNext())
                {
                    task = enumerator.Current;
                    BudTask item = (from p in this.budTaskSer
                                    where p.TaskId == task.TaskId
                                    select p).FirstOrDefault <BudTask>();
                    if ((item != null) && (budModify.Flowstate == 1))
                    {
                        if (task.ModifyType == 0)
                        {
                            item.IsValid = true;
                            this.budTaskSer.Update(item);
                            this.budModifyTaskSer.UpdateTotal2(task.ModifyTaskId);
                        }
                        if (item.ModifyId != task.ModifyId)
                        {
                            item.ModifyId = task.ModifyId;
                            item.Total2  += task.Total2;
                            decimal?quantity = item.Quantity;
                            decimal num      = task.Quantity;
                            item.Quantity = quantity.HasValue ? new decimal?(quantity.GetValueOrDefault() + num) : null;
                            if (item.Quantity != 0M)
                            {
                                item.UnitPrice = item.Total2 / item.Quantity;
                            }
                            this.budTaskSer.Update(item);
                            this.budModifyTaskSer.UpdateTotal2(task.ModifyTaskId);
                        }
                    }
                }
            }
            string cmdText = string.Format(" SELECT * FROM Con_Modify_Stock  where ModifyId='{0}' ", primarykey);

            if (SqlHelper.ExecuteQuery(CommandType.Text, cmdText, null).Rows.Count != 0)
            {
                string    str2   = string.Format("SELECT ModifyStock.*FROM Con_Modify_Stock ModifyStock\r\n                                            INNER JOIN Sm_Purchase_Stock purchaseStock ON ModifyStock.purchaseId=purchaseStock.psid\r\n                                            WHERE ModifyId='{0}'", primarykey);
                DataTable table2 = SqlHelper.ExecuteQuery(CommandType.Text, str2, null);
                string    str3   = string.Format("SELECT purchaseStock.* FROM Sm_Purchase_Stock purchaseStock \r\n                                                  LEFT JOIN (SELECT *FROM Con_Modify_Stock  where ModifyId='{0}') ModifyStock\r\n                                                  ON purchaseStock.psid=ModifyStock.purchaseId\r\n                                                  WHERE purchaseStock.pscode in (SELECT DISTINCT Pscode FROM Con_Modify_Stock WHERE ModifyId='{0}')\r\n                                                  AND ModifyStockId IS NULL", primarykey);
                DataTable table3 = SqlHelper.ExecuteQuery(CommandType.Text, str3, null);
                string    str4   = string.Format("SELECT ModifyStock.* FROM Con_Modify_Stock ModifyStock\r\n                                               LEFT JOIN Sm_Purchase_Stock purchaseStock ON ModifyStock.purchaseId=purchaseStock.psid\r\n                                               WHERE ModifyId='{0}'AND psid IS NULL", primarykey);
                DataTable table4 = SqlHelper.ExecuteQuery(CommandType.Text, str4, null);
                using (SqlConnection connection = new SqlConnection(SqlHelper.ConnectionString))
                {
                    connection.Open();
                    SqlTransaction trans = connection.BeginTransaction();
                    foreach (DataRow row in table2.Rows)
                    {
                        PurchaseStockModel model = new PurchaseStockModel {
                            psid   = row["PurchaseId"].ToString(),
                            sprice = DBHelper.GetDecimal(row["Sprice"]),
                            number = DBHelper.GetDecimal(row["Quantity"]),
                            corp   = DBHelper.GetString(row["Corp"])
                        };
                        if (row["ArrivalDate"] != null)
                        {
                            model.ArrivalDate = row["ArrivalDate"].ToString();
                        }
                        else
                        {
                            model.ArrivalDate = null;
                        }
                        model.pscode = row["Pscode"].ToString();
                        model.scode  = row["Scode"].ToString();
                        this.purchaseSotck.Update(trans, model);
                    }
                    foreach (DataRow row2 in table3.Rows)
                    {
                        this.purchaseSotck.Delete(trans, row2["psid"].ToString());
                    }
                    foreach (DataRow row3 in table4.Rows)
                    {
                        PurchaseStockModel model2 = new PurchaseStockModel {
                            psid   = row3["PurchaseId"].ToString(),
                            sprice = DBHelper.GetDecimal(row3["Sprice"]),
                            number = DBHelper.GetDecimal(row3["Quantity"]),
                            corp   = DBHelper.GetString(row3["Corp"])
                        };
                        if (row3["ArrivalDate"] != null)
                        {
                            model2.ArrivalDate = row3["ArrivalDate"].ToString();
                        }
                        else
                        {
                            model2.ArrivalDate = null;
                        }
                        model2.pscode = row3["Pscode"].ToString();
                        model2.scode  = row3["Scode"].ToString();
                        this.purchaseSotck.Add(trans, model2);
                    }
                    trans.Commit();
                    return;
                }
            }
            string    str5   = string.Format("\r\n\t\t\t\t\t\t\t\t\tSELECT PCode FROM Sm_Purchase purchase\r\n\t\t\t\t\t\t\t\t\tINNER JOIN Con_Payout_Modify payoutModify ON purchase.Contract=payoutModify.ContractId\r\n\t\t\t\t\t\t\t\t\tWHERE ModifyId='{0}' AND purchase.FlowState=1", primarykey);
            DataTable table5 = SqlHelper.ExecuteQuery(CommandType.Text, str5, null);

            if (table5.Rows.Count > 0)
            {
                using (SqlConnection connection2 = new SqlConnection(SqlHelper.ConnectionString))
                {
                    connection2.Open();
                    SqlTransaction transaction2 = connection2.BeginTransaction();
                    foreach (DataRow row4 in table5.Rows)
                    {
                        this.purchaseSotck.DeleteByPscode(transaction2, row4["PCode"].ToString());
                    }
                    transaction2.Commit();
                }
            }
        }