예제 #1
0
        public int GetFormulaResult(string formulaStr, doorTypeInfo door)
        {
            DataTable dt      = new DataTable();
            string    formstr = formulaStr;

            formstr = formstr.Replace("W", door.Width.ToString());
            formstr = formstr.Replace("H", door.Height.ToString());
            object result    = dt.Compute(formstr, "");
            int    resultInt = 0;

            if (int.TryParse(result.ToString(), out resultInt))
            {
            }

            return(resultInt);
        }
예제 #2
0
        //获取门皮 门板 码头等尺寸 门型 还他妈的有字母和文字
        public bool getSizeDataTable(doorTypeInfo door)
        {
            string doorType = door.Name; //志邦的 20190418

            // string doorType = ConstantMethod.getCharacter(door.Name)+ ConstantMethod.getNumber(door.Name);

            foreach (sizeLstByDoorType split in UserSplitType)
            {
                if (split.Name.Equals(doorType)) //志邦的 20190418
                //匹配成功 找到公式  找到尺寸
                //if (split.Name.Contains(doorType))

                {
                    foreach (singleSize size in split.Size)
                    {
                        //刨花板 桥洞力学板
                        if (size.Formula.Count == 2)
                        {
                            //当公式有两个的时候
                            switch (size.Sizeid)
                            {
                            case Constant.doorBanId:
                            {
                                DataRow dr = door.Door_Ban.NewRow();
                                dr[Constant.strformatZh[0]]  = GetFormulaResult(size.Formula[0].Strexe, door);
                                dr[Constant.strformatZh[1]]  = size.Count;       // GetFormulaResult(size.Formula[0].Strexe, door);
                                dr[Constant.strformatZh[2]]  = "0";
                                dr[Constant.strformatZh[3]]  = size.Name;
                                dr[Constant.strformatZh[4]]  = GetFormulaResult(size.Formula[1].Strexe, door);
                                dr[Constant.strformatZh[5]]  = door.Xuhao;
                                dr[Constant.strformatZh[13]] = door.Xuhao;
                                door.Door_Ban.Rows.Add(dr);

                                break;
                            }

                            case Constant.doorShellId:
                            {
                                //添加门皮
                                DataRow dr0 = door.Door_shell.NewRow();
                                dr0[Constant.strformatZh[0]] = GetFormulaResult(size.Formula[0].Strexe, door);
                                dr0[Constant.strformatZh[1]] = "1";        //门皮两个一起切
                                dr0[Constant.strformatZh[2]] = "0";
                                dr0[Constant.strformatZh[3]] = size.Name;
                                int shellWidth = GetFormulaResult(size.Formula[1].Strexe, door);
                                if (shellWidth < 610)
                                {
                                    MessageBox.Show("门皮数据超范围,请检查数据后再拆单!");
                                    return(false);
                                }
                                dr0[Constant.strformatZh[4]] = GetFormulaResult(size.Formula[1].Strexe, door);
                                door.Door_shell.Rows.Add(dr0);
                                dr0[Constant.strformatZh[5]]  = door.Xuhao;
                                dr0[Constant.strformatZh[13]] = door.Xuhao;
                                break;
                            }
                            }
                        }
                        else
                        {
                            //添加尺寸条子
                            if (size.Formula.Count == 1 && size.Sizeid == Constant.doorSizeId)
                            {
                                DataRow dr = door.Door_Size.NewRow();

                                dr[Constant.strformatZh[0]]  = GetFormulaResult(size.Formula[0].Strexe, door);
                                dr[Constant.strformatZh[1]]  = size.Count;// GetFormulaResult(size.Formula[0].Strexe, door);
                                dr[Constant.strformatZh[2]]  = "0";
                                dr[Constant.strformatZh[5]]  = door.Xuhao;
                                dr[Constant.strformatZh[13]] = door.Xuhao;// doorType+door.GwId;
                                // dr[Constant.strformatZh[15]] = door.GwId;

                                if (door.BarCodeStr.Count > 13)
                                {
                                    dr[Constant.strformatZh[3]]  = door.BarCodeStr[0];
                                    dr[Constant.strformatZh[4]]  = door.BarCodeStr[1];
                                    dr[Constant.strformatZh[6]]  = door.BarCodeStr[2];
                                    dr[Constant.strformatZh[7]]  = door.BarCodeStr[3];
                                    dr[Constant.strformatZh[8]]  = door.BarCodeStr[4];
                                    dr[Constant.strformatZh[9]]  = door.BarCodeStr[5];
                                    dr[Constant.strformatZh[10]] = door.BarCodeStr[6];
                                    dr[Constant.strformatZh[11]] = door.BarCodeStr[7];
                                    dr[Constant.strformatZh[12]] = door.BarCodeStr[8];
                                    //dr[Constant.strformatZh[13]] = door.BarCodeStr[9];
                                    dr[Constant.strformatZh[14]] = door.BarCodeStr[9];
                                    dr[Constant.strformatZh[15]] = door.BarCodeStr[11];
                                    dr[Constant.strformatZh[16]] = door.BarCodeStr[12];
                                    dr[Constant.strformatZh[17]] = door.BarCodeStr[13];
                                }
                                door.Door_Size.Rows.Add(dr);
                            }
                        }
                    }
                }
            }

            return(true);
        }
예제 #3
0
        public bool LoadDoorTypeDataTable(string filename, List <doorTypeInfo> doorLst)
        {
            DataTable doorType = exop.ImportExcel(filename);

            if (doorType.Rows.Count > 0)
            {
                doorLst.Clear();
            }
            else
            {
                return(false);
            }
            string[] gwid      = { "1", "2", "3" };
            int      gwidCount = 0;

            foreach (DataRow dr in doorType.Rows)
            {
                doorTypeInfo door = new doorTypeInfo();

                door.Name = dr[valCol["产品名称"]].ToString();

                double height = 0;
                string s      = dr[valCol["高"]].ToString();
                if (!double.TryParse(dr[valCol["高"]].ToString(), out height))
                {
                    MessageBox.Show("门高数据错误!");
                    return(false);
                }

                door.Height = (int)height;

                double width = 0;
                if (!double.TryParse(dr[valCol["宽"]].ToString(), out width))
                {
                    MessageBox.Show("门宽数据错误!");
                    return(false);
                }
                door.Width = (int)width;

                double thickness = 0;
                if (!double.TryParse(dr[valCol["厚"]].ToString(), out width))
                {
                    MessageBox.Show("门厚数据错误!");
                    return(false);
                }
                door.Thickness = (int)thickness;

                int cnt = 0;
                if (!int.TryParse(dr[valCol["数量"]].ToString(), out cnt))
                {
                    MessageBox.Show("门数量数据错误!");
                    return(false);
                }
                door.Count = cnt;

                door.BarCodeStr.Add(dr[valCol["门扇条码"]].ToString());
                foreach (string key in valCol.Keys)
                {
                    door.BarCodeStr.Add(dr[valCol[key]].ToString());
                }

                door.Xuhao = dr[valCol["总序号"]].ToString();

                doorLst.Add(door);
                door.GwId = gwid[gwidCount];


                gwidCount++;
                if (gwidCount >= gwid.Count())
                {
                    gwidCount = 0;
                }
                if (!getSizeDataTable(door))
                {
                    return(false);
                }
            }

            return(true);
        }