/// <summary>
        /// 删除
        /// </summary>
        /// <param name="p_BE">要删除的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RDelete(int p_BE, IDBTransAccess sqlTrans)
        {
            try
            {
                BProductCheckDtsFault entity = new BProductCheckDtsFault(sqlTrans);
                entity.ID = p_BE;
                entity.SelectByID();
                RDelete(entity, sqlTrans);
                BProductCheckDts en = new BProductCheckDts(sqlTrans);
                en.ID = entity.MainID;
                en.SelectByID();
                en.CY -= entity.CYQty;

                string sql = "";
                en.RCKF  = 0m;
                en.CJRC  = 0m;
                en.FMRC  = 0m;
                en.ZCKF  = 0m;
                en.CJZC  = 0m;
                en.FMZC  = 0m;
                en.MQty3 = 0m;
                #region 统计合计数据
                sql = "SELECT SUM(DQuantity) DQuantity,SUM(Deduction) Deduction,SUM(DYM) DYM,B.CDType FROM WO_BProductCheckDtsFault AS A,Data_CDGL AS B WHERE A.FaultDes=B.Code AND A.MainID=" + entity.MainID + " GROUP BY B.CDType";
                DataTable dt = sqlTrans.Fill(sql);
                foreach (DataRow dr in dt.Rows)
                {
                    if (dr["CDType"].ToString() == "染疵")
                    {
                        // DQuantity// 放码
                        //Deduction扣分
                        //DYM 裁剪
                        en.RCKF = SysConvert.ToDecimal(dr["Deduction"]);
                        en.CJRC = SysConvert.ToDecimal(dr["DYM"]);
                        en.FMRC = SysConvert.ToDecimal(dr["DQuantity"]);
                    }
                    else if (dr["CDType"].ToString() == "织疵")
                    {
                        en.ZCKF = SysConvert.ToDecimal(dr["Deduction"]);
                        en.CJZC = SysConvert.ToDecimal(dr["DYM"]);
                        en.FMZC = SysConvert.ToDecimal(dr["DQuantity"]);
                    }
                    else
                    {
                        en.MQty3 = SysConvert.ToDecimal(dr["DQuantity"]);
                    }
                }

                BProductCheckDtsRule rulebp2 = new BProductCheckDtsRule();
                rulebp2.RUpdate(en, sqlTrans);
                #endregion
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 新增(传入事务处理)
        /// </summary>
        /// <param name="p_BE">要新增的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RSubmitInWH(List <BProductCheckDts> p_BE, string WHID, string SectionID, IDBTransAccess sqlTrans)
        {
            try
            {
                string CheckItem = GetListID(p_BE);
                //1检验是否入库
                string    sql = "SELECT StatusID,ID FROM WO_BProductCheckDts WHERE StatusID>" + (int)EnumBoxStatus.未入库 + " AND ID IN (" + CheckItem + ")";
                DataTable dt  = sqlTrans.Fill(sql);
                if (dt.Rows.Count != 0)
                {
                    BProductCheckDts entity = new BProductCheckDts(sqlTrans);
                    entity.ID = SysConvert.ToInt32(dt.Rows[0]["ID"]);
                    entity.SelectByID();
                    throw new Exception("条码" + entity.DISN + " 已经入库请检查");
                }

                //2校验通过,开始创建入库单。
                sql  = "SELECT ItemCode,ItemName,ItemStd,ItemModel,ColorNum,ColorName,JarNum,MF,KZ,ShopID,VendorID,SUM(Qty) Qty,SUM(YQty) Weight,DLever,CompactNo,SaleOPID,JSUnit FROM UV1_WO_BProductCheckDts WHERE DID IN(" + CheckItem + ")";
                sql += " GROUP BY ItemCode,ItemName,ItemStd,ItemModel,ColorNum,ColorName,JarNum,MF,KZ,ShopID,VendorID,DLever,CompactNo,SaleOPID,JSUnit";
                dt   = sqlTrans.Fill(sql);

                sql = "SELECT DISTINCT ShopID FROM UV1_WO_BProductCheckDts WHERE DID IN(" + CheckItem + ")";
                DataTable dtshop = sqlTrans.Fill(sql);//本次勾选的是那几家染厂的数据


                sql = "SELECT * FROM UV1_WO_BProductCheckDts WHERE DID IN(" + CheckItem + ")";

                DataTable dtall = sqlTrans.Fill(sql);

                foreach (DataRow drshop in dtshop.Rows)//一家染厂一个入库单
                {
                    IOForm IOentity = new IOForm(sqlTrans);

                    IOentity.FormDate = DateTime.Now.Date;

                    IOentity.WHID     = WHID;
                    IOentity.WHType   = WHID;
                    IOentity.HeadType = 11;
                    IOentity.SubType  = 1107;

                    IOentity.VendorID = drshop["ShopID"].ToString();

                    FormNoControlRule ruleno = new FormNoControlRule();
                    IOentity.FormNo = ruleno.RGetWHFormNo(IOentity.HeadType, IOentity.SubType, IOentity.WHID, sqlTrans);
                    IOentity.Remark = "检验后入库";

                    DataRow[]   Shopinwh  = dt.Select("ShopID=" + SysString.ToDBString(drshop["ShopID"].ToString()));//一家染厂多个缸号或品种
                    IOFormDts[] entitydts = new IOFormDts[Shopinwh.Length];
                    ArrayList   List      = new ArrayList();
                    int         i         = 0;
                    foreach (DataRow drinwh in Shopinwh)//一家染厂多个缸号或品种
                    {
                        entitydts[i]           = new IOFormDts(sqlTrans);
                        entitydts[i].Seq       = i + 1;
                        entitydts[i].WHID      = IOentity.WHID;
                        entitydts[i].SectionID = SectionID;
                        entitydts[i].SBitID    = "";

                        entitydts[i].ItemCode = drinwh["ItemCode"].ToString();
                        //entitydts[i].CPItemCode = entitydts[i].ItemCode;
                        entitydts[i].ItemName  = drinwh["ItemName"].ToString();
                        entitydts[i].ItemModel = drinwh["ItemName"].ToString();
                        entitydts[i].ItemStd   = drinwh["ItemStd"].ToString();
                        entitydts[i].ItemModel = drinwh["ItemModel"].ToString();
                        entitydts[i].ColorNum  = drinwh["ColorNum"].ToString();
                        entitydts[i].ColorName = drinwh["ColorName"].ToString();
                        entitydts[i].JarNum    = drinwh["JarNum"].ToString();

                        entitydts[i].MWeight = SysConvert.ToDecimal(drinwh["KZ"]);
                        entitydts[i].MWidth  = SysConvert.ToDecimal(drinwh["MF"]);

                        entitydts[i].DtsSO          = drinwh["CompactNo"].ToString();
                        entitydts[i].DtsOrderFormNo = drinwh["CompactNo"].ToString();
                        //entitydts[i].DtsOrderFormNo = drinwh["SO"].ToString();
                        //entitydts[i].InSO = drinwh["SO"].ToString();
                        entitydts[i].InSaleOPID  = drinwh["SaleOPID"].ToString();
                        entitydts[i].DtsVendorID = drinwh["VendorID"].ToString();
                        entitydts[i].GoodsLevel  = drinwh["DLever"].ToString();
                        entitydts[i].Qty         = SysConvert.ToDecimal(drinwh["Qty"]);
                        entitydts[i].Weight      = SysConvert.ToDecimal(drinwh["Weight"]);
                        entitydts[i].Remark      = "检验入成品库";
                        entitydts[i].Unit        = drinwh["JSUnit"].ToString();
                        entitydts[i].PackFlag    = 1;//细码标志
                        // ItemCode,ItemName,ItemStd,ColorNum,ColorName,JarNum,ShopID,VendorID,SUM(Qty) Qty,SUM(YQty) Weight,DLever,CompactNo,SO,SaleOPID
                        // ,,,,,,,,SUM(Qty) Qty,SUM(YQty) Weight,,,,

                        DataRow[] ISN = dtall.Select("ISNULL(ItemCode,'')=" + SysString.ToDBString(drinwh["ItemCode"].ToString())
                                                     + " AND ISNULL(ItemName,'')=" + SysString.ToDBString(drinwh["ItemName"].ToString())
                                                     + " AND ISNULL(ItemStd,'')=" + SysString.ToDBString(drinwh["ItemStd"].ToString())
                                                     + " AND ISNULL(ItemModel,'')=" + SysString.ToDBString(drinwh["ItemModel"].ToString())
                                                     + " AND ISNULL(ColorName,'')=" + SysString.ToDBString(drinwh["ColorName"].ToString())
                                                     + " AND ISNULL(ColorNum,'')=" + SysString.ToDBString(drinwh["ColorNum"].ToString())
                                                     + " AND ISNULL(JarNum,'')=" + SysString.ToDBString(drinwh["JarNum"].ToString())
                                                     //+ " AND ISNULL(MF,'')=" + SysString.ToDBString(drinwh["MF"].ToString())
                                                     //      + " AND ISNULL(KZ,'')=" + SysString.ToDBString(drinwh["KZ"].ToString())
                                                     + " AND ISNULL(ShopID,'')=" + SysString.ToDBString(dt.Rows[i]["ShopID"].ToString())
                                                     + " AND ISNULL(VendorID,'')=" + SysString.ToDBString(dt.Rows[i]["VendorID"].ToString())
                                                     + " AND ISNULL(DLever,'')=" + SysString.ToDBString(dt.Rows[i]["DLever"].ToString())
                                                     + " AND ISNULL(CompactNo,'')=" + SysString.ToDBString(dt.Rows[i]["CompactNo"].ToString())
                                                     + " AND ISNULL(SaleOPID,'')=" + SysString.ToDBString(dt.Rows[i]["SaleOPID"].ToString()));
                        entitydts[i].PieceQty = ISN.Length;

                        int m = 0;
                        foreach (DataRow dr in ISN)
                        {
                            IOFormDtsPack entity = new IOFormDtsPack(sqlTrans);
                            entity.Seq    = i + 1;
                            entity.SubSeq = m + 1;
                            entity.BoxNo  = dr["DISN"].ToString();

                            entity.Qty = SysConvert.ToDecimal(dr["Qty"]);

                            entity.Remark = "检验入成品库";
                            List.Add(entity);

                            m++;
                        }
                        i++;
                    }

                    decimal TotalQty = 0;
                    for (int j = 0; j < entitydts.Length; j++)
                    {
                        TotalQty += entitydts[j].Qty;
                    }

                    IOentity.TotalQty = TotalQty;



                    IOFormRule rule2 = new IOFormRule();
                    rule2.RAdd(IOentity, entitydts, List, sqlTrans);



                    rule2.RSubmit(IOentity.ID, (int)ConfirmFlag.已提交, sqlTrans);
                }

                //3更新条码状态(这步动作是在入库提交的时候处理)
                sql = "Update WO_BProductCheckDts Set InWHFlag=1 WHERE ID IN(" + CheckItem + ")";
                sqlTrans.ExecuteNonQuery(sql);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
        /// <summary>
        /// 检验结束
        /// </summary>
        /// <param name="p_BE">要删除的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public int RJYEnd(int p_BE, BProductCheckDts entity2, int p_PackID, decimal Qty, decimal YMQty, int JarNo, IDBTransAccess sqlTrans)
        {
            try
            {
                if (p_BE == 0)//如果是0 则表示没有疵点
                {
                    entity2.MainID = p_PackID;

                    BProductCheckDtsRule rulebp = new BProductCheckDtsRule();

                    rulebp.RAdd(entity2, sqlTrans);

                    p_BE = entity2.ID;
                }
                BProductCheckDts entity = new BProductCheckDts(sqlTrans);
                entity.ID = p_BE;

                entity.SelectByID();
                entity.MainID     = p_PackID;
                entity.YM         = YMQty;
                entity.SM         = Qty;                        //码表数量
                entity.FMQty      = entity2.FMQty;              //放码数量
                entity.KZ         = entity2.KZ;                 //克重
                entity.MF         = entity2.MF;                 //门幅
                entity.WX         = entity2.WX;                 //纬斜
                entity.PrintCD    = entity2.PrintCD;            //打印疵点项目
                entity.ColorName  = entity2.ColorName;          //颜色
                entity.ColorNum   = entity2.ColorNum;           //色号
                entity.GoodsLevel = entity2.GoodsLevel;         //等级
                entity.Qty        = entity2.SM - entity2.FMQty; //数量=码表数量-放码数量

                string sqls = "Select ISNULL(Max(JarNo),0) From WO_BProductCheckDts where JarNum=" + SysString.ToDBString(SysConvert.ToString(entity.JarNum));
                sqls += " AND ItemCode=" + SysString.ToDBString(SysConvert.ToString(entity.ItemCode));
                sqls += " AND ColorNum=" + SysString.ToDBString(SysConvert.ToString(entity.ColorNum));
                DataTable dts = sqlTrans.Fill(sqls);
                if ((SysConvert.ToInt32(dts.Rows[0][0]) + 1) != JarNo)
                {
                    entity.JarNo = SysConvert.ToInt32(dts.Rows[0][0]) + 1;//卷号
                }
                else
                {
                    entity.JarNo = JarNo;//卷号
                }

                entity.ShopID = entity2.ShopID;

                entity.YQty = SysConvert.ToDecimal(Qty * 1.0936132983377m, 2);//米数转码数
                BProductCheckDtsRule rule = new BProductCheckDtsRule();
                rule.RUpdate(entity, sqlTrans);



                #region 统计合计数据
                entity.RCKF  = 0m;
                entity.CJRC  = 0m;
                entity.FMRC  = 0m;
                entity.ZCKF  = 0m;
                entity.CJZC  = 0m;
                entity.FMZC  = 0m;
                entity.MQty3 = 0m;
                string    sql = "SELECT SUM(DQuantity) DQuantity,SUM(Deduction) Deduction,SUM(DYM) DYM,B.CDType FROM WO_BProductCheckDtsFault AS A,Data_CDGL AS B WHERE A.FaultDes=B.Code AND A.MainID=" + p_BE + " GROUP BY B.CDType";
                DataTable dt  = sqlTrans.Fill(sql);
                foreach (DataRow dr in dt.Rows)
                {
                    if (dr["CDType"].ToString() == "染疵")
                    {
                        entity.RCKF = SysConvert.ToDecimal(dr["Deduction"]);
                        entity.CJRC = SysConvert.ToDecimal(dr["DYM"]);
                        entity.FMRC = SysConvert.ToDecimal(dr["DQuantity"]);
                    }
                    else if (dr["CDType"].ToString() == "织疵")
                    {
                        entity.ZCKF = SysConvert.ToDecimal(dr["Deduction"]);
                        entity.CJZC = SysConvert.ToDecimal(dr["DYM"]);
                        entity.FMZC = SysConvert.ToDecimal(dr["DQuantity"]);
                    }
                    else
                    {
                        //entity.MQty3 = SysConvert.ToDecimal(dr["DQuantity"]);
                        entity.ZCKF = SysConvert.ToDecimal(dr["Deduction"]);
                        entity.CJZC = SysConvert.ToDecimal(dr["DYM"]);
                        entity.FMZC = SysConvert.ToDecimal(dr["DQuantity"]);
                    }
                }

                entity.SJQty = SysConvert.ToDecimal(entity.SM - entity.CJZC - entity.CJRC - entity.FMQty, 1);//实际数量=码表数量-裁剪数量-放码数量
                BProductCheckDtsRule rulebp2 = new BProductCheckDtsRule();
                rulebp2.RUpdate(entity, sqlTrans);



                #endregion


                #region 合计检验米数汇总到待检清单

                sql = "Select SUM(Qty) Qty from WO_BProductCheckDts where MainID=" + p_PackID;
                DataTable dtS = sqlTrans.Fill(sql);
                if (dtS.Rows.Count != 0)
                {
                    sql  = "Update WO_PackOrderDts Set CheckQty=" + SysConvert.ToDecimal(dtS.Rows[0]["Qty"]);
                    sql += " where ID=" + p_PackID;
                    sqlTrans.ExecuteNonQuery(sql);
                }
                #endregion


                return(p_BE);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 新增(传入事务处理)
        /// </summary>
        /// <param name="p_BE">要新增的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void ModifyLog(BProductCheckDts p_BE, BProductCheckDtsModifyLog p_BE2, IDBTransAccess sqlTrans)
        {
            try
            {
                if (p_BE.StatusID != (int)EnumBoxStatus.未入库)
                {
                    throw new Exception("不是已经出库的条码,不能修改");
                }

                if (p_BE.KF24 == 1)
                {
                    throw new Exception("此匹布已经修改过一次了,不能在此修改");
                }

                #region 备份的老条码
                BProductCheckDts entityold = new BProductCheckDts(sqlTrans);
                entityold.ID = p_BE.ID;
                entityold.SelectByID();//复制的老条码
                #endregion


                #region 更新老的条码为新的条码,只换条码号,和修改的内容,其他信息不变
                if (p_BE2.CompactNo != string.Empty)
                {
                    p_BE2.OldCompactNo = p_BE.CompactNo;

                    p_BE.CompactNo = p_BE2.CompactNo;

                    string    sqlcheck = "SELECT ID FROM Sale_SaleOrder WHERE FormNo=" + SysString.ToDBString(p_BE2.CompactNo) + " AND SubmitFlag=1";
                    DataTable dtcheck  = sqlTrans.Fill(sqlcheck);
                    if (dtcheck.Rows.Count != 1)
                    {
                        throw new Exception("变更的合同号不存在,请检查");
                    }
                }
                if (p_BE2.JarNum != string.Empty)
                {
                    p_BE2.OldJarNum = p_BE.JarNum;


                    p_BE.JarNum = p_BE2.JarNum;
                }

                if (p_BE2.Seq != 0)
                {
                    p_BE2.OldSeq = p_BE.Seq;

                    p_BE.Seq = p_BE2.Seq;
                }



                p_BE.KF24     = 0;
                p_BE.KF22     = 1;//退货冲销后产生的新的条码
                p_BE.DISN     = GetDISN(sqlTrans);
                p_BE.StatusID = (int)EnumBoxStatus.未入库;
                RUpdate2(p_BE, sqlTrans);

                #endregion


                #region 备份老的条码,标志为不可修改,并增加Log日志
                p_BE2.ModifyID     = p_BE.ID;
                entityold.StatusID = (int)EnumBoxStatus.未入库;
                entityold.KF24     = 1;//修改后新产生条码

                entityold.ID = 0;
                RAdd2(entityold, sqlTrans);
                p_BE2.NewISNID = entityold.ID;//新产生条码的ID
                BProductCheckDtsModifyLogRule rule = new BProductCheckDtsModifyLogRule();
                rule.RAdd(p_BE2, sqlTrans);
                #endregion
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }