Пример #1
0
        /// <summary>
        /// 设置数据
        /// </summary>
        /// <param name="bomId"></param>
        public void SetDelData(int bomId)
        {
            detailBiz    = new Bom_opcomponent(ref conn, bomId, ufConnStr, opertype);
            detailSubBiz = new Bom_opcomponentsub(ref conn, bomId, ufConnStr, opertype);

            //主表  bom_bom
            DataSet   dsMainBom = new DataSet();
            DataTable dtMainBom = GetBomHeadByBomId(bomId);

            dsMainBom.Tables.Add(dtMainBom.Copy());
            //子表 bom_
            DataSet   dsBom = new DataSet();
            DataTable dtBom = GetChildByBomId(bomId);

            dsBom.Tables.Add(dtBom.Copy());
            //替代料
            DataSet   dsSubChildBom = new DataSet();
            DataTable dtSubChildBom = GetSubChildByBomId(bomId);

            dsSubChildBom.Tables.Add(dtSubChildBom.Copy());


            //表头
            for (int i = 0; i < dsMainBom.Tables.Count; i++)
            {
                if (dsMainBom.Tables[i].Rows.Count > 0)
                {
                    for (int j = 0; j < dsMainBom.Tables[i].Rows.Count; j++)
                    {
                        List <BaseMode> tmpMainLst = new List <BaseMode>();
                        // h.InvCode,h.InvName,h.version,h.bomid, h.VersionEffDate
                        tmpMainLst.Add(new BaseMode("bomid", Convert.ToString(bomId), null, "bomid", dsMainBom.Tables[i].Rows[j]["bomid"].ToString(), null, null));
                        tmpMainLst.Add(new BaseMode(null, null, null, "Version", dsMainBom.Tables[i].Rows[j]["version"].ToString(), null, null));
                        tmpMainLst.Add(new BaseMode(null, null, null, "VersionEffDate", dsMainBom.Tables[i].Rows[j]["VersionEffDate"].ToString(), null, null));
                        tmpMainLst.Add(new BaseMode(null, null, null, "cInvCode", dsMainBom.Tables[i].Rows[j]["InvCode"].ToString(), null, null));
                        tmpMainLst.Add(new BaseMode(null, null, null, "status", "0", null, null));
                        tmpMainLst.Add(new BaseMode(null, null, null, "opertype", "2", null, null));
                        this.lst.Add(tmpMainLst);
                    }
                }
            }
            //DataTable dtLocation = GetLocation(bomId);
            //表体
            for (int mti = 0; mti < dsBom.Tables.Count; mti++)
            {
                if (dsBom.Tables[mti].Rows.Count > 0)
                {
                    for (int j = 0; j < dsBom.Tables[mti].Rows.Count; j++)
                    {
                        //材料
                        List <BaseMode> tmpDetailLst  = new List <BaseMode>();
                        string          matid         = Guid.NewGuid().ToString();
                        string          opcomponentid = dsBom.Tables[mti].Rows[j]["OpComponentId"].ToString();
                        tmpDetailLst.Add(new BaseMode(null, null, null, "did", matid, null, null));
                        tmpDetailLst.Add(new BaseMode(null, null, null, "cInvCode", dsBom.Tables[mti].Rows[j]["DInvCode"].ToString(), null, null));
                        tmpDetailLst.Add(new BaseMode(null, null, null, "BaseQtyN", dsBom.Tables[mti].Rows[j]["DBaseQtyN"].ToString(), null, null));
                        tmpDetailLst.Add(new BaseMode(null, null, null, "BaseQtyD", dsBom.Tables[mti].Rows[j]["DBaseQtyD"].ToString(), null, null));
                        tmpDetailLst.Add(new BaseMode(null, null, null, "opertype", "2", null, null));
                        detailBiz.lst.Add(tmpDetailLst);


                        //替代料
                        for (int f = 0; f < dsSubChildBom.Tables.Count; f++)
                        {
                            if (dsSubChildBom.Tables[f].Rows.Count > 0)
                            {
                                DataRow[] dr = dsSubChildBom.Tables[f].Select("OpComponentId =" + opcomponentid);
                                for (int h = 0; h < dr.Length; h++)
                                {
                                    List <BaseMode> tmpDetailSubLst = new List <BaseMode>();

                                    tmpDetailSubLst.Add(new BaseMode(null, null, null, "did", matid, null, null));
                                    tmpDetailSubLst.Add(new BaseMode(null, null, null, "ddid", Guid.NewGuid().ToString(), null, null));
                                    tmpDetailSubLst.Add(new BaseMode(null, null, null, "cInvCode", dr[h]["cInvCode"].ToString(), null, null));
                                    tmpDetailSubLst.Add(new BaseMode(null, null, null, "Sequence", dr[h]["Sequence"].ToString(), null, null));
                                    tmpDetailSubLst.Add(new BaseMode(null, null, null, "Factor", dr[h]["Factor"].ToString(), null, null));
                                    tmpDetailSubLst.Add(new BaseMode(null, null, null, "ReplaceFlag", dr[h]["ReplaceFlag"].ToString(), null, null));

                                    if (opertype.Equals("a"))
                                    {
                                        tmpDetailSubLst.Add(new BaseMode(null, null, null, "opertype", "0", null, null));
                                    }
                                    else
                                    {
                                        tmpDetailSubLst.Add(new BaseMode(null, null, null, "opertype", "2", null, null));
                                    }
                                    detailSubBiz.lst.Add(tmpDetailSubLst);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 保存时,默认为审核状态,需要往MES表中插入数据
        /// ITEMCODE
        /// SBITEMCODE
        /// SBSITEMCODE
        /// SBITEMQTY
        /// SBITEMECN
        /// SBITEMEFFDATE
        /// SBITEMINVDATE
        /// SBITEMUOM
        /// SBOMVER
        /// LOCATION
        /// </summary>
        /// <param name="doc"></param>
        public void SetAddData(ref DataSet ds)
        {
            detailBiz = new Bom_opcomponent(ref conn, bomId, ufConnStr, opertype);

            //主表
            string InvCode;
            string VersionEffDate;
            string VersionEndDate;
            string version;
            string BomId;

            string DInvCode;
            string DInvUnit;

            List <BaseMode> tmpMainLst = new List <BaseMode>();

            //for (int i = 0; i < ds.Tables["StandardBom"].Rows.Count; i++)
            //{
            BomId          = ds.Tables["StandardBom"].Rows[0]["BomId"].ToString();
            InvCode        = GetInvCodeByPartid(ds.Tables["BomParent"].Rows[0]["ParentId"].ToString());
            version        = ds.Tables["StandardBom"].Rows[0]["Version"].ToString();
            VersionEffDate = ds.Tables["StandardBom"].Rows[0]["VersionEffDate"].ToString();
            VersionEndDate = ds.Tables["StandardBom"].Rows[0]["VersionEndDate"].ToString();


            tmpMainLst.Add(new BaseMode(null, null, null, "id", "main|##newguid", null, null));
            tmpMainLst.Add(new BaseMode("bomid", BomId, null, "bomid", BomId, null, null));
            tmpMainLst.Add(new BaseMode(null, null, null, "Version", version, null, null));
            tmpMainLst.Add(new BaseMode(null, null, null, "VersionEffDate", VersionEffDate, null, null));
            tmpMainLst.Add(new BaseMode(null, null, null, "cInvCode", InvCode, null, null));
            tmpMainLst.Add(new BaseMode(null, null, null, "status", "0", null, null));
            if (opertype.Equals("a"))
            {
                tmpMainLst.Add(new BaseMode(null, null, null, "opertype", "0", null, null));
            }
            else
            {
                tmpMainLst.Add(new BaseMode(null, null, null, "opertype", "2", null, null));
            }


            this.lst.Add(tmpMainLst);
            //}


            //子件表
            for (int i = 0; i < ds.Tables["BomComponents"].Rows.Count; i++)
            {
                List <BaseMode> tmpDetailLst = new List <BaseMode>();

                if (ds.Tables["BomComponents"].Rows[i].RowState.ToString().ToLower().Equals("deleted"))
                {
                    continue;
                }
                DInvCode = GetInvCodeByPartid(ds.Tables["BomComponents"].Rows[i]["ComponentId"].ToString());

                tmpDetailLst.Add(new BaseMode(null, null, null, "id", "main|##newguid", null, null));
                tmpDetailLst.Add(new BaseMode(null, null, null, "did", Guid.NewGuid().ToString(), null, null));
                tmpDetailLst.Add(new BaseMode(null, null, null, "cInvCode", DInvCode, null, null));
                tmpDetailLst.Add(new BaseMode(null, null, null, "BaseQtyN", ds.Tables["BomComponents"].Rows[i]["BaseQtyN"].ToString(), null, null));
                tmpDetailLst.Add(new BaseMode(null, null, null, "BaseQtyD", ds.Tables["BomComponents"].Rows[i]["BaseQtyD"].ToString(), null, null));
                if (opertype.Equals("a"))
                {
                    tmpDetailLst.Add(new BaseMode(null, null, null, "opertype", "0", null, null));
                }
                else
                {
                    tmpDetailLst.Add(new BaseMode(null, null, null, "opertype", "2", null, null));
                }
                detailBiz.lst.Add(tmpDetailLst);
            }

            //替代料 ds.Tables["ComponentSubstitutes"]
        }