Beispiel #1
0
 public DataView getDS(string TypeName)
 {
     if (TypeName == "Measure")
     {
         Hownet.BLL.Measure bllM = new Measure();
         return(bllM.GetAllList().Tables[0].DefaultView);
     }
     else if (TypeName == "Company")
     {
         Hownet.BLL.Company bllC = new Company();
         return(bllC.GetList("TypeID=1").Tables[0].DefaultView);
     }
     else if (TypeName == "Materiel")
     {
         Hownet.BLL.Materiel bllMat = new Materiel();
         return(bllMat.GetList("AttributeID=1").Tables[0].DefaultView);
     }
     else if (TypeName == "VerifyMan")
     {
         Hownet.BLL.Users bllU = new Users();
         return(bllU.GetAllList().Tables[0].DefaultView);
     }
     else if (TypeName == "ProductsType")
     {
         Hownet.BLL.MaterielType bllMT = new MaterielType();
         return(bllMT.GetList("AttributeID=1").Tables[0].DefaultView);
     }
     else
     {
         DataView dv = new DataView();
         return(dv);
     }
 }
        public DataTable GroupTable(DataTable dt, DataTable dtSouGong)
        {
            bool t = false;

            Hownet.BLL.Materiel          bllMat = new Materiel();
            Hownet.BLL.MaterielAttribute bllMA  = new MaterielAttribute();
            Hownet.BLL.Department        bllDep = new Department();
            DataTable dtMD = dtSouGong.Clone();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                for (int j = 0; j < dtMD.Rows.Count; j++)
                {
                    t = false;
                    if (dt.DefaultView[i]["MaterielID"].Equals(dtMD.DefaultView[j]["MaterielID"]) && dt.DefaultView[i]["ColorID"].Equals(dtMD.DefaultView[j]["ColorID"]) &&
                        dt.DefaultView[i]["DepartmentID"].Equals(dtMD.DefaultView[j]["TaskID"]) && dt.DefaultView[i]["ProductTaskID"].Equals(dtMD.DefaultView[j]["ProduceTaskID"]) &&
                        dt.DefaultView[i]["SizeID"].Equals(dtMD.DefaultView[j]["SizeID"]) && dt.DefaultView[i]["BrandID"].Equals(dtMD.DefaultView[j]["BrandID"]) &&
                        dt.DefaultView[i]["ColorOneID"].Equals(dtMD.DefaultView[j]["ColorOneID"]) && dt.DefaultView[i]["ColorTwoID"].Equals(dtMD.DefaultView[j]["ColorTwoID"]))
                    {
                        dtMD.Rows[j]["EligibleAmount"] = int.Parse(dt.DefaultView[i]["EligibleAmount"].ToString()) + int.Parse(dtMD.DefaultView[j]["EligibleAmount"].ToString());
                        dtMD.Rows[j]["InferiorAmount"] = int.Parse(dt.DefaultView[i]["InferiorAmount"].ToString()) + int.Parse(dtMD.DefaultView[j]["InferiorAmount"].ToString());
                        t = true;
                        break;
                    }
                }
                if (!t)
                {
                    DataRow dr = dtMD.NewRow();
                    dr["MaterielID"]     = dt.DefaultView[i]["MaterielID"];
                    dr["ColorID"]        = dt.DefaultView[i]["ColorID"];
                    dr["SizeID"]         = dt.DefaultView[i]["SizeID"];
                    dr["TaskID"]         = dt.DefaultView[i]["DepartmentID"];
                    dr["ProduceTaskID"]  = dt.DefaultView[i]["ProductTaskID"];
                    dr["EligibleAmount"] = dt.DefaultView[i]["EligibleAmount"];
                    dr["InferiorAmount"] = dt.DefaultView[i]["InferiorAmount"];
                    dr["BrandID"]        = dt.DefaultView[i]["BrandID"];
                    dr["ColorOneID"]     = dt.DefaultView[i]["ColorOneID"];
                    dr["ColorTwoID"]     = dt.DefaultView[i]["ColorTwoID"];
                    dtMD.Rows.Add(dr);
                }
            }
            for (int i = 0; i < dtSouGong.Rows.Count; i++)
            {
                for (int j = 0; j < dtMD.Rows.Count; j++)
                {
                    t = false;
                    if (dtSouGong.DefaultView[i][2].Equals(dtMD.DefaultView[j][2]) && dtSouGong.DefaultView[i][3].Equals(dtMD.DefaultView[j][3]) &&
                        dtSouGong.DefaultView[i][5].Equals(dtMD.DefaultView[j][5]) && dtSouGong.DefaultView[i][6].Equals(dtMD.DefaultView[j][6]) &&
                        dtSouGong.DefaultView[i][9].Equals(dtMD.DefaultView[j][9]) && dtSouGong.DefaultView[i]["BrandID"].Equals(dtMD.DefaultView[j]["BrandID"]) &&
                        dtSouGong.DefaultView[i]["ColorOneID"].Equals(dtMD.DefaultView[j]["ColorOneID"]) && dtSouGong.DefaultView[i]["ColorTwoID"].Equals(dtMD.DefaultView[j]["ColorTwoID"]))
                    {
                        dtMD.Rows[j]["EligibleAmount"] = int.Parse(dtSouGong.DefaultView[i]["EligibleAmount"].ToString()) + int.Parse(dtMD.DefaultView[j]["EligibleAmount"].ToString());
                        dtMD.Rows[j]["InferiorAmount"] = int.Parse(dtSouGong.DefaultView[i]["InferiorAmount"].ToString()) + int.Parse(dtMD.DefaultView[j]["InferiorAmount"].ToString());
                        t = true;
                        break;
                    }
                }
                if (!t)
                {
                    DataRow dr = dtMD.NewRow();
                    dr["MaterielID"]     = dtSouGong.DefaultView[i]["MaterielID"];
                    dr["ColorID"]        = dtSouGong.DefaultView[i]["ColorID"];
                    dr["SizeID"]         = dtSouGong.DefaultView[i]["SizeID"];
                    dr["TaskID"]         = dtSouGong.DefaultView[i]["TaskID"];
                    dr["ProduceTaskID"]  = dtSouGong.DefaultView[i]["ProduceTaskID"];
                    dr["EligibleAmount"] = dtSouGong.DefaultView[i]["EligibleAmount"];
                    dr["InferiorAmount"] = dtSouGong.DefaultView[i]["InferiorAmount"];
                    dr["BrandID"]        = dtSouGong.DefaultView[i]["BrandID"];
                    dr["ColorOneID"]     = dtSouGong.DefaultView[i]["ColorOneID"];
                    dr["ColorTwoID"]     = dtSouGong.DefaultView[i]["ColorTwoID"];
                    dtMD.Rows.Add(dr);
                }
            }
            DataTable dtMat = bllMat.GetList("(AttributeID=1) OR (AttributeID=5)").Tables[0];
            DataTable dtMA  = bllMA.GetAllList().Tables[0];
            DataTable dtDep = bllDep.GetTypeList("иВок").Tables[0];

            dtMD.Columns.Add("MaterielName", typeof(string));
            dtMD.Columns.Add("ColorName", typeof(string));
            dtMD.Columns.Add("SizeName", typeof(string));
            dtMD.Columns.Add("DeparmentName", typeof(string));
            dtMD.Columns.Add("BrandName", typeof(string));
            dtMD.Columns.Add("ColorOneName", typeof(string));
            dtMD.Columns.Add("ColorTwoName", typeof(string));
            for (int i = 0; i < dtMD.Rows.Count; i++)
            {
                dtMD.Rows[i]["MaterielName"]  = dtMat.Select("(MaterielID=" + dtMD.Rows[i]["MaterielID"] + ")")[0]["MaterielName"];
                dtMD.Rows[i]["ColorName"]     = dtMA.Select("(MaterielAttributeID=" + dtMD.Rows[i]["ColorID"] + ")")[0]["MaterielAttributeName"];
                dtMD.Rows[i]["SizeName"]      = dtMA.Select("(MaterielAttributeID=" + dtMD.Rows[i]["SizeID"] + ")")[0]["MaterielAttributeName"];
                dtMD.Rows[i]["DeparmentName"] = dtDep.Select("(DepartmentID=" + dtMD.Rows[i]["TaskID"] + ")")[0]["DepartmentName"];
                if (dtMD.Rows[i]["BrandID"].ToString() != "0")
                {
                    dtMD.Rows[i]["BrandName"] = dtMat.Select("(MaterielID=" + dtMD.Rows[i]["BrandID"] + ")")[0]["MaterielName"];
                }
                if (dtMD.Rows[i]["ColorOneID"].ToString() != "0")
                {
                    dtMD.Rows[i]["ColorOneName"] = dtMA.Select("(MaterielAttributeID=" + dtMD.Rows[i]["ColorOneID"] + ")")[0]["MaterielAttributeName"];
                }
                if (dtMD.Rows[i]["ColorTwoID"].ToString() != "0")
                {
                    dtMD.Rows[i]["ColorTwoName"] = dtMA.Select("(MaterielAttributeID=" + dtMD.Rows[i]["ColorTwoID"] + ")")[0]["MaterielAttributeName"];
                }
                object obj = dtMD.Rows[i]["BrandID"];
            }
            return(dtMD);
        }