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)
         {
         }
     }
 }
 protected void btnSave_Click(object sender, System.EventArgs e)
 {
     try
     {
         System.Collections.Generic.List <ResType> list = new System.Collections.Generic.List <ResType>();
         foreach (GridViewRow gridViewRow in this.gvwResType.Rows)
         {
             string       id           = this.gvwResType.DataKeys[gridViewRow.RowIndex].Value.ToString();
             ResType      byId         = ResType.GetById(id);
             DropDownList dropDownList = (DropDownList)gridViewRow.FindControl("ddlCBS");
             if (!string.IsNullOrEmpty(dropDownList.SelectedValue.Trim()))
             {
                 byId.CBSCode = dropDownList.SelectedValue.Trim();
             }
             else
             {
                 byId.CBSCode = null;
             }
             list.Add(byId);
         }
         ResType.Update(list);
         base.RegisterScript("alert('系统提示:\\n修改成功!');");
     }
     catch
     {
         base.RegisterScript("alert('系统提示:\\n修改失败!');");
     }
 }
Example #3
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');");
    }