Example #1
0
 protected void AddResToDB(DataRow row, string resTypeId)
 {
     if (row != null)
     {
         string  id   = System.Guid.NewGuid().ToString();
         ResType byId = ResType.GetById(resTypeId);
         string  code = row[1].ToString();
         string  name = row[2].ToString();
         row[3].ToString();
         string  s = row[7].ToString();
         decimal value;
         decimal.TryParse(s, out value);
         string id2 = ConfigHelper.Get("BudgetPriceType");
         System.Collections.Generic.Dictionary <ResPriceType, decimal?> dictionary = new System.Collections.Generic.Dictionary <ResPriceType, decimal?>();
         ResPriceType byId2 = ResPriceType.GetById(id2);
         dictionary.Add(byId2, new decimal?(value));
         try
         {
             cn.justwin.Domain.Resource resource = cn.justwin.Domain.Resource.Create(id, byId, code, name, string.Empty, null, string.Empty, string.Empty, string.Empty, null, null, string.Empty, dictionary, this.inputUser, new System.DateTime?(System.DateTime.Now), null);
             cn.justwin.Domain.Resource.Add(resource);
         }
         catch (System.Exception)
         {
         }
     }
 }
Example #2
0
 protected void btnSave_ServerClick(object sender, System.EventArgs e)
 {
     try
     {
         BudTemplateItem byId = BudTemplateItem.GetById(this.itemId, this.tempId);
         System.Collections.Generic.List <TaskResource> resources = new System.Collections.Generic.List <TaskResource>();
         byId.Resources = resources;
         for (int i = 0; i < this.gvResource.Rows.Count; i++)
         {
             cn.justwin.Domain.Resource byId2 = cn.justwin.Domain.Resource.GetById(this.gvResource.DataKeys[i].Values[0].ToString());
             decimal quantity        = System.Convert.ToDecimal(((TextBox)this.gvResource.Rows[i].FindControl("txtNumber")).Text);
             decimal price           = System.Convert.ToDecimal(((TextBox)this.gvResource.Rows[i].FindControl("txtPrice")).Text);
             decimal lossCoefficient = System.Convert.ToDecimal(((TextBox)this.gvResource.Rows[i].FindControl("txtLossCoefficient")).Text);
             byId.AddResource(byId2, quantity, price, PageHelper.QueryUser(this, base.UserCode), System.DateTime.Now, "save", lossCoefficient);
         }
         BudTemplateItem.AddResource(byId);
         base.RegisterScript("$('#btnBindResource').hide(); top.ui.show('保存成功!')");
         base.RegisterScript(string.Concat(new string[]
         {
             "winclose('ResourceList', 'BudTemplateList.aspx?tempId=",
             this.tempId,
             "&tempType=",
             this.tempType,
             "', true)"
         }));
         this.BindGv();
     }
     catch (System.Exception)
     {
     }
 }
Example #3
0
 protected void btnSave_ServerClick(object sender, System.EventArgs e)
 {
     try
     {
         System.Collections.Generic.List <TaskResource> list = new System.Collections.Generic.List <TaskResource>();
         cn.justwin.Domain.BudTask budTask = null;
         if (this.hfldIsWBSRelevance.Value == "1")
         {
             budTask           = cn.justwin.Domain.BudTask.GetById(this.taskId);
             budTask.Resources = list;
         }
         for (int i = 0; i < this.gvResource.Rows.Count; i++)
         {
             cn.justwin.Domain.Resource byId = cn.justwin.Domain.Resource.GetById(this.gvResource.DataKeys[i].Values[0].ToString());
             decimal quantity = System.Convert.ToDecimal(((TextBox)this.gvResource.Rows[i].FindControl("txtNumber")).Text);
             decimal price    = System.Convert.ToDecimal(((TextBox)this.gvResource.Rows[i].FindControl("txtPrice")).Text);
             decimal num      = System.Convert.ToDecimal(((TextBox)this.gvResource.Rows[i].FindControl("txtLoss")).Text);
             if (this.hfldIsWBSRelevance.Value == "1")
             {
                 budTask.AddResource(byId, quantity, price, num, "save");
             }
             else
             {
                 list.Add(new TaskResource
                 {
                     Resource        = byId,
                     Quantity        = quantity,
                     Price           = price,
                     PrjGuid         = this.prjId,
                     Versions        = System.Convert.ToInt32(this.hfldVersion.Value.Trim()),
                     InputDate       = new System.DateTime?(System.DateTime.Now),
                     InputUser       = PageHelper.QueryUser(this, base.UserCode),
                     LossCoefficient = new decimal?(num)
                 });
             }
         }
         if (this.hfldIsWBSRelevance.Value == "1")
         {
             budTask.InputUser = PageHelper.QueryUser(this, base.UserCode);
             budTask.InputDate = System.DateTime.Now;
             cn.justwin.Domain.BudTask.AddResource(budTask);
             BudTaskService budTaskService = new BudTaskService();
             budTaskService.UpdateTotal2(this.taskId);
         }
         else
         {
             TaskResource.AddResource(list, this.prjId, System.Convert.ToInt32(this.hfldVersion.Value));
         }
         base.RegisterScript("top.ui.tabSuccess({ parentName: '_ResourceDeploy' });");
     }
     catch (System.Exception)
     {
     }
 }
Example #4
0
    protected void ImportResource(DataTable dtExcelInfo, System.Collections.Generic.Dictionary <string, int> dicRes)
    {
        System.Collections.Generic.List <string> priceTypeCodes = ResPriceType.GetPriceTypeCodes();
        string text = PageHelper.QueryUser(this, base.UserCode);
        int    num  = 0;

        for (int i = 0; i < dtExcelInfo.Rows.Count; i++)
        {
            DataRow dataRow = dtExcelInfo.Rows[i];
            string  text2   = dataRow[dicRes["ResourceCode"]].ToString();
            bool    flag    = this.IsExistResourceCode(text2);
            if (flag)
            {
                Label  expr_57 = this.lblErrorMsg;
                string text3   = expr_57.Text;
                expr_57.Text = string.Concat(new string[]
                {
                    text3,
                    "<div align='left' style=' margin-top:3px; padding-left:15px;  border-bottom-style:solid; border-bottom-color:#cccccc; border-bottom-width:1px;  background-color:white; line-height:28px; height:28px; text-align:left;'>在您的Excel中:",
                    dtExcelInfo.Columns[dicRes["ResourceCode"]].ColumnName,
                    "<span style='color:green;'>",
                    text2,
                    "</span>,此编码已经存在导入失败!</div>"
                });
            }
            else
            {
                string text4 = dtExcelInfo.Rows[i][dicRes["ResourceName"]].ToString();
                if (!string.IsNullOrEmpty(text2) && !string.IsNullOrEmpty(text4))
                {
                    string  brand   = dicRes.Keys.Any((string a) => a == "Brand") ? dataRow[dicRes["Brand"]].ToString() : string.Empty;
                    string  text5   = dicRes.Keys.Any((string a) => a == "TaxRate") ? dataRow[dicRes["TaxRate"]].ToString() : string.Empty;
                    decimal?taxRate = null;
                    decimal value;
                    if (!string.IsNullOrEmpty(text5) && decimal.TryParse(text5, out value))
                    {
                        taxRate = new decimal?(value);
                    }
                    string specification  = dicRes.Keys.Any((string a) => a == "Specification") ? dataRow[dicRes["Specification"]].ToString() : string.Empty;
                    string technicalParam = dicRes.Keys.Any((string a) => a == "TechnicalParameter") ? dataRow[dicRes["TechnicalParameter"]].ToString() : string.Empty;
                    string text6          = dicRes.Keys.Any((string a) => a == "Unit") ? dataRow[dicRes["Unit"]].ToString() : string.Empty;
                    if (string.IsNullOrEmpty(text6))
                    {
                        text6 = "xx";
                    }
                    string attributeName    = dicRes.Keys.Any((string a) => a == "Attribute") ? dataRow[dicRes["Attribute"]].ToString() : string.Empty;
                    string series           = dicRes.Keys.Any((string a) => a == "Series") ? dataRow[dicRes["Series"]].ToString() : string.Empty;
                    string supplierName     = dicRes.Keys.Any((string a) => a == "SupplierId") ? dataRow[dicRes["SupplierId"]].ToString() : string.Empty;
                    int?   supplierIdByName = cn.justwin.Domain.Resource.GetSupplierIdByName(supplierName);
                    string modelNumber      = dicRes.Keys.Any((string a) => a == "ModelNumber") ? dataRow[dicRes["ModelNumber"]].ToString() : string.Empty;
                    if (!dicRes.Keys.Any((string a) => a == "Note"))
                    {
                        string arg_400_0 = string.Empty;
                    }
                    else
                    {
                        dataRow[dicRes["Note"]].ToString();
                    }
                    System.Collections.Generic.Dictionary <ResPriceType, decimal?> dictionary = new System.Collections.Generic.Dictionary <ResPriceType, decimal?>();
                    foreach (string key in dicRes.Keys)
                    {
                        bool flag2 = priceTypeCodes.Any((string a) => a == key);
                        if (flag2)
                        {
                            string  s = dataRow[dicRes[key]].ToString();
                            decimal value2;
                            decimal.TryParse(s, out value2);
                            dictionary.Add(ResPriceType.GetByTypeCode(key), new decimal?(value2));
                        }
                    }
                    ResType                    byId            = ResType.GetById(base.Request["parentId"]);
                    ResUnit                    unit            = this.GetUnit(text6, text);
                    ResTypeAttribute           byAttributeName = ResTypeAttribute.GetByAttributeName(attributeName);
                    cn.justwin.Domain.Resource resource        = cn.justwin.Domain.Resource.Create(System.Guid.NewGuid().ToString(), byId, text2, text4, brand, taxRate, specification, modelNumber, technicalParam, unit, byAttributeName, series, dictionary, text, new System.DateTime?(System.DateTime.Now), supplierIdByName);
                    cn.justwin.Domain.Resource.Add(resource);
                    num++;
                }
            }
        }
        if (num == 0)
        {
            base.RegisterScript("alert('系统提示:\\n数据导入失败!');setTem('2');");
            return;
        }
        if (num == dtExcelInfo.Rows.Count)
        {
            base.RegisterScript("alert('系统提示:\\n数据导入成功!');setTem('2');closePage();");
            return;
        }
        base.RegisterScript("alert('系统提示:\\n数据导入成功!');setTem('2');");
    }