Ejemplo n.º 1
0
 private string ImportSingle(string val)
 {
     try
     {
         string[] arr = ImportRule.SplitCsvLine(val);
         if (arr.Length < base.MinColCount)
         {
             return(string.Format("列不足{0}个", base.MinColCount));
         }
         string text = arr[1].Trim();
         if (text == "")
         {
             return("材料名称为空");
         }
         string text2 = arr[0].Trim();
         string text3 = "";
         if (text2 != "")
         {
             DataRow[] rowArray = this.m_tbSystemGroup.Select("FullName = '" + text2 + "'");
             if (rowArray.Length > 0)
             {
                 text3 = rowArray[0]["GroupCode"].ToString();
             }
         }
         if (text3 == "")
         {
             return(string.Format("未知的类型“{0}”", text2));
         }
         MaterialDAL   ldal = new MaterialDAL(this.conn);
         MaterialModel mObj = new MaterialModel();
         mObj.MaterialCode = int.Parse(SystemManageDAO.GetNewSysCode("MaterialCode"));
         mObj.MaterialName = text;
         mObj.GroupCode    = text3;
         mObj.Spec         = ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 2)).Trim();
         mObj.Unit         = ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 3)).Trim();
         mObj.InputPerson  = this.InputPerson;
         try
         {
             if (ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 4)).Trim() == "")
             {
                 mObj.StandardPrice = 0M;
             }
             else
             {
                 mObj.StandardPrice = decimal.Parse(ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 4)).Trim());
             }
         }
         catch
         {
             return(string.Format("参考价“{0}”不是有效的数值", ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 4)).Trim()));
         }
         mObj.Remark = ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 5)).Trim();
         ldal.Insert(mObj);
     }
     catch (Exception exception)
     {
         throw exception;
     }
     return("");
 }
Ejemplo n.º 2
0
        public DataRow ImportSupplierMaterialSingle(string val, EntityData entity, ref string hint, ref string SupplierName, ref string GroupFullName, bool isTest, DataTable tbAllSystemGroup)
        {
            Exception exception;

            hint = "";
            DataRow row = null;

            try
            {
                int        index;
                DataRow    row2;
                string     text4;
                DataColumn column;
                string     s;
                string[]   arr = ImportRule.SplitCsvLine(val);
                if (arr.Length < base.MinColCount)
                {
                    hint = string.Format("列不足{0}个", base.MinColCount);
                    return(null);
                }
                SupplierName  = arr[1].Trim();
                GroupFullName = "";
                if (SupplierName == "")
                {
                    hint = "厂商为空";
                    return(null);
                }
                string text  = arr[0].Trim();
                string text2 = "";
                if (text != "")
                {
                    DataRow[] rowArray = tbAllSystemGroup.Select("FullName = '" + text + "'");
                    if (rowArray.Length > 0)
                    {
                        text2         = rowArray[0]["GroupCode"].ToString();
                        GroupFullName = text;
                    }
                }
                if (text2 == "")
                {
                    hint = string.Format("未知的类型“{0}”", text);
                    return(null);
                }
                string supplierCodeByName = "";
                if (SupplierName != "")
                {
                    supplierCodeByName = ProjectRule.GetSupplierCodeByName(SupplierName);
                }
                if (supplierCodeByName == "")
                {
                    hint = string.Format("厂商信息中找不到厂商“{0}”", SupplierName);
                    return(null);
                }
                int count = base.tbDefine.Rows.Count;
                for (index = 0; index < count; index++)
                {
                    row2  = base.tbDefine.Rows[index];
                    text4 = row2["FieldName"].ToString();
                    string text5 = row2["FieldDesc"].ToString();
                    column = entity.CurrentTable.Columns[text4];
                    if ((text4 != "") && (text4 != "GroupCode"))
                    {
                        s = ConvertRule.ToString(ConvertRule.GetArrayItem(arr, index)).Trim();
                        if ((column.DataType == typeof(string)) && (StringRule.LenB(s) > column.MaxLength))
                        {
                            hint = string.Format("{0}({1})长度超过{2}位(现为{3}位)", new object[] { text5, s, column.MaxLength, s.Length });
                            return(null);
                        }
                    }
                }
                row = entity.CurrentTable.NewRow();
                try
                {
                    if (isTest)
                    {
                        row["SupplierMaterialCode"] = Guid.NewGuid().ToString();
                    }
                    else
                    {
                        row["SupplierMaterialCode"] = SystemManageDAO.GetNewSysCode("SupplierMaterialCode").ToString();
                    }
                    count = base.tbDefine.Rows.Count;
                    for (index = 0; index < count; index++)
                    {
                        row2   = base.tbDefine.Rows[index];
                        text4  = row2["FieldName"].ToString();
                        column = entity.CurrentTable.Columns[text4];
                        if (text4 != "")
                        {
                            string text7 = text4;
                            if (text7 == null)
                            {
                                goto Label_03AE;
                            }
                            if (text7 != "GroupCode")
                            {
                                if (text7 == "SupplierCode")
                                {
                                    goto Label_03A1;
                                }
                                goto Label_03AE;
                            }
                            row[text4] = text2;
                        }
                        continue;
Label_03A1:
                        row[text4] = supplierCodeByName;
                        continue;
Label_03AE:
                        s = ConvertRule.ToString(ConvertRule.GetArrayItem(arr, index)).Trim();
                        if (s == "")
                        {
                            try
                            {
                                row[text4] = s;
                            }
                            catch
                            {
                                row[text4] = DBNull.Value;
                            }
                        }
                        else
                        {
                            row[text4] = s;
                        }
                    }
                    entity.CurrentTable.Rows.Add(row);
                }
                catch (Exception exception1)
                {
                    exception = exception1;
                    row       = null;
                    throw exception;
                }
            }
            catch (Exception exception2)
            {
                exception = exception2;
                hint      = "异常出错:" + exception.Message;
            }
            return(row);
        }
Ejemplo n.º 3
0
        public DataRow ImportSupplierSingle(string val, EntityData entity, ref string hint, ref string SupplierName, ref string SupplierTypeFullName, bool isTest, DataTable tbAllSystemGroup)
        {
            hint = "";
            DataRow row = null;

            try
            {
                int        index;
                DataRow    row2;
                string     text3;
                DataColumn column;
                string     text5;
                string[]   arr = ImportRule.SplitCsvLine(val);
                if (arr.Length < base.MinColCount)
                {
                    hint = "列不足3个";
                    return(null);
                }
                SupplierName         = arr[0].Trim();
                SupplierTypeFullName = "";
                if (SupplierName == "")
                {
                    hint = "厂商名称为空";
                    return(null);
                }
                string text  = arr[2].Trim();
                string text2 = "";
                if (text != "")
                {
                    DataRow[] rowArray = tbAllSystemGroup.Select("FullName = '" + text + "'");
                    if (rowArray.Length > 0)
                    {
                        text2 = rowArray[0]["GroupCode"].ToString();
                        SupplierTypeFullName = text;
                    }
                }
                if (text2 == "")
                {
                    hint = string.Format("未知的厂商类型“{0}”", text);
                    return(null);
                }
                int count = base.tbDefine.Rows.Count;
                for (index = 0; index < count; index++)
                {
                    row2  = base.tbDefine.Rows[index];
                    text3 = row2["FieldName"].ToString();
                    string text4 = row2["FieldDesc"].ToString();
                    column = entity.CurrentTable.Columns[text3];
                    if ((text3 != "") && (text3 != "SupplierTypeCode"))
                    {
                        text5 = ConvertRule.ToString(ConvertRule.GetArrayItem(arr, index)).Trim();
                        if ((column.DataType == typeof(string)) && (text5.Length > column.MaxLength))
                        {
                            hint = string.Format("{0}({1})长度超过{2}位(现为{3}位)", new object[] { text4, text5, column.MaxLength, text5.Length });
                            return(null);
                        }
                    }
                }
                DataRow[] rowArray2 = entity.CurrentTable.Select("SupplierName='" + SupplierName + "' and SupplierTypeCode = '" + text2 + "'");
                if (rowArray2.Length > 0)
                {
                    row = rowArray2[0];
                }
                else
                {
                    row = entity.CurrentTable.NewRow();
                    if (isTest)
                    {
                        row["SupplierCode"] = Guid.NewGuid().ToString();
                    }
                    else
                    {
                        row["SupplierCode"] = SystemManageDAO.GetNewSysCode("SupplierCode").ToString();
                    }
                    entity.CurrentTable.Rows.Add(row);
                }
                count = base.tbDefine.Rows.Count;
                for (index = 0; index < count; index++)
                {
                    row2   = base.tbDefine.Rows[index];
                    text3  = row2["FieldName"].ToString();
                    column = entity.CurrentTable.Columns[text3];
                    if (text3 != "")
                    {
                        string text6 = text3;
                        if ((text6 != null) && (text6 == "SupplierTypeCode"))
                        {
                            row[text3] = text2;
                        }
                        else
                        {
                            text5 = ConvertRule.ToString(ConvertRule.GetArrayItem(arr, index)).Trim();
                            if (text5 == "")
                            {
                                try
                                {
                                    row[text3] = text5;
                                }
                                catch
                                {
                                    row[text3] = DBNull.Value;
                                }
                            }
                            else
                            {
                                row[text3] = text5;
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                hint = "异常出错:" + exception.Message;
            }
            return(row);
        }
Ejemplo n.º 4
0
            protected int ImportRow(string sline, EntityData entity, ref string hint, ref string Name)
            {
                int num = -1;

                hint = "";
                try
                {
                    int     index;
                    DataRow row;
                    string  fieldName;
                    string  val;
                    if (sline.Trim() == "")
                    {
                        hint = "行为空";
                        return(num);
                    }
                    string[] arr = ImportRule.SplitCsvLine(sline);
                    if (arr.Length < this.MinColCount)
                    {
                        hint = string.Format("列不足{0}个", this.MinColCount);
                        return(num);
                    }
                    int count = this.tbDefine.Rows.Count;
                    for (index = 0; index < count; index++)
                    {
                        row       = this.tbDefine.Rows[index];
                        fieldName = ConvertRule.ToString(row["FieldName"]);
                        string text2 = ConvertRule.ToString(row["FieldName"]);
                        bool   flag  = ConvertRule.ToBool(row["NotNull"]);
                        val = ConvertRule.ToString(ConvertRule.GetArrayItem(arr, index)).Trim();
                        if (flag && (val == ""))
                        {
                            hint = string.Format("{0}不能为空", text2);
                            return(num);
                        }
                        if (!this.CustomCheckValid(fieldName, val, text2, ref hint))
                        {
                            return(num);
                        }
                    }
                    if (!this.CustomCheckValid(arr, ref hint))
                    {
                        return(num);
                    }
                    if (this.ImportNewRow(arr) == null)
                    {
                        throw new Exception("未定义导入函数ImportNewRow");
                    }
                    for (index = 0; index < count; index++)
                    {
                        row       = this.tbDefine.Rows[index];
                        fieldName = row["FieldName"].ToString();
                        if (fieldName != "")
                        {
                            val = ConvertRule.ToString(ConvertRule.GetArrayItem(arr, index)).Trim();
                            this.GetImportFieldValue(fieldName, val);
                        }
                    }
                    num = 1;
                }
                catch (Exception exception)
                {
                    hint = "异常出错:" + exception.Message;
                }
                return(num);
            }
Ejemplo n.º 5
0
        public DataRow ImportMaterialCostSingle(string val, EntityData entity, ref string hint, ref string Description, ref string GroupFullName, bool isTest, DataTable tbAllSystemGroup)
        {
            Exception exception;

            hint = "";
            DataRow row = null;

            try
            {
                int        index;
                DataRow    row2;
                string     text3;
                DataColumn column;
                string     s;
                string[]   arr = ImportRule.SplitCsvLine(val);
                if (arr.Length < base.MinColCount)
                {
                    hint = "列不足3个";
                    return(null);
                }
                Description   = arr[6].Trim();
                GroupFullName = "";
                if (Description == "")
                {
                    hint = "描述为空";
                    return(null);
                }
                string text  = arr[0].Trim();
                string text2 = "";
                if (text != "")
                {
                    DataRow[] rowArray = tbAllSystemGroup.Select("FullName = '" + text + "'");
                    if (rowArray.Length > 0)
                    {
                        text2         = rowArray[0]["GroupCode"].ToString();
                        GroupFullName = text;
                    }
                }
                if (text2 == "")
                {
                    hint = string.Format("未知的类型“{0}”", text);
                    return(null);
                }
                int count = base.tbDefine.Rows.Count;
                for (index = 0; index < count; index++)
                {
                    row2  = base.tbDefine.Rows[index];
                    text3 = row2["FieldName"].ToString();
                    string text4 = row2["FieldDesc"].ToString();
                    column = entity.CurrentTable.Columns[text3];
                    if ((text3 != "") && (text3 != "GroupCode"))
                    {
                        s = ConvertRule.ToString(ConvertRule.GetArrayItem(arr, index)).Trim();
                        if ((column.DataType == typeof(string)) && (StringRule.LenB(s) > column.MaxLength))
                        {
                            hint = string.Format("{0}({1})长度超过{2}位(现为{3}位)", new object[] { text4, s, column.MaxLength, s.Length });
                            return(null);
                        }
                    }
                }
                row = entity.CurrentTable.NewRow();
                try
                {
                    if (isTest)
                    {
                        row["MaterialCostCode"] = Guid.NewGuid().ToString();
                    }
                    else
                    {
                        row["MaterialCostCode"] = SystemManageDAO.GetNewSysCode("MaterialCostCode").ToString();
                    }
                    count = base.tbDefine.Rows.Count;
                    for (index = 0; index < count; index++)
                    {
                        row2   = base.tbDefine.Rows[index];
                        text3  = row2["FieldName"].ToString();
                        column = entity.CurrentTable.Columns[text3];
                        if (text3 != "")
                        {
                            string text6 = text3;
                            if ((text6 != null) && (text6 == "GroupCode"))
                            {
                                row[text3] = text2;
                            }
                            else
                            {
                                s = ConvertRule.ToString(ConvertRule.GetArrayItem(arr, index)).Trim();
                                if (s == "")
                                {
                                    try
                                    {
                                        row[text3] = s;
                                    }
                                    catch
                                    {
                                        row[text3] = DBNull.Value;
                                    }
                                }
                                else
                                {
                                    row[text3] = s;
                                }
                            }
                        }
                    }
                    entity.CurrentTable.Rows.Add(row);
                }
                catch (Exception exception1)
                {
                    exception = exception1;
                    row       = null;
                    throw exception;
                }
            }
            catch (Exception exception2)
            {
                exception = exception2;
                hint      = "异常出错:" + exception.Message;
            }
            return(row);
        }
Ejemplo n.º 6
0
 private string ImportSingle(string val)
 {
     try
     {
         string[] arr = ImportRule.SplitCsvLine(val);
         if (arr.Length < base.MinColCount)
         {
             return(string.Format("列不足{0}个", base.MinColCount));
         }
         string text = arr[0].Trim();
         if (text == "")
         {
             return("项目名称为空");
         }
         string text2 = arr[1].Trim();
         string text3 = "";
         if (text2 != "")
         {
             DataRow[] rowArray = this.m_tbSystemGroup.Select("FullName = '" + text2 + "'");
             if (rowArray.Length > 0)
             {
                 text3 = rowArray[0]["GroupCode"].ToString();
             }
         }
         if (text3 == "")
         {
             return(string.Format("未知的费用项“{0}”", text2));
         }
         ProjectCostDAL   tdal = new ProjectCostDAL(this.conn);
         ProjectCostModel mObj = new ProjectCostModel();
         mObj.ProjectCostCode = int.Parse(SystemManageDAO.GetNewSysCode("ProjectCostCode"));
         mObj.ProjectName     = text;
         mObj.GroupCode       = text3;
         mObj.Unit            = ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 3)).Trim();
         mObj.InputPerson     = this.InputPerson;
         try
         {
             if (ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 2)).Trim() == "")
             {
                 mObj.Area = 0M;
             }
             else
             {
                 mObj.Area = decimal.Parse(ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 2)).Trim());
             }
         }
         catch
         {
             return(string.Format("面积“{0}”不是有效的数值", ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 2)).Trim()));
         }
         try
         {
             if (ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 3)).Trim() == "")
             {
                 mObj.Price = 0M;
             }
             else
             {
                 mObj.Price = decimal.Parse(ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 3)).Trim());
             }
         }
         catch
         {
             return(string.Format("单方造价“{0}”不是有效的数值", ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 3)).Trim()));
         }
         try
         {
             if (ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 4)).Trim() == "")
             {
                 mObj.Money = 0M;
             }
             else
             {
                 mObj.Money = decimal.Parse(ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 4)).Trim());
             }
         }
         catch
         {
             return(string.Format("总价“{0}”不是有效的数值", ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 4)).Trim()));
         }
         try
         {
             if (ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 5)).Trim() == "")
             {
                 mObj.Qty = 0M;
             }
             else
             {
                 mObj.Qty = decimal.Parse(ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 5)).Trim());
             }
         }
         catch
         {
             return(string.Format("数量“{0}”不是有效的数值", ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 5)).Trim()));
         }
         if (((mObj.Money == 0M) && (mObj.Price != 0M)) && (mObj.Area != 0M))
         {
             mObj.Money = Math.Round((decimal)(mObj.Price * mObj.Area), 2);
         }
         if (((mObj.Price == 0M) && (mObj.Money != 0M)) && (mObj.Area != 0M))
         {
             mObj.Price = Math.Round((decimal)(mObj.Money / mObj.Area), 2);
         }
         mObj.Remark = ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 5)).Trim();
         tdal.Insert(mObj);
     }
     catch (Exception exception)
     {
         throw exception;
     }
     return("");
 }