Exemple #1
0
        /// <summary>
        /// 删除单据
        /// </summary>
        /// <param name="UserCode"></param>
        /// <param name="PlainPassword"></param>
        /// <param name="StrAccID"></param>
        /// <param name="AccYear"></param>
        /// <param name="Act"></param>
        /// <param name="entity"></param>
        /// <param name="success"></param>
        /// <returns></returns>
        public string DelRdRecord01(string UserCode, string PlainPassword,
                                    string StrAccID, int AccYear, string Act, EntityRdRecord01Head entity, out int success)
        {
            success = 1;
            string        msg = "";
            RdRecord01Bll bll = new RdRecord01Bll(StrAccID, AccYear, UserCode, PlainPassword);

            if (bll.GetGlmendFlag(entity.dDate.Year, entity.dDate.Month, "bflag_ST") == true)
            {
                success = 0;
                return(string.Format("U8单据{0}日期所在月份已经结账!", entity.cCode));
            }
            if (GetRdRecord01(entity.cCode) != 0)
            {
                if (RdRecord01Checked(entity.cCode) == 0)
                {
                    msg     = string.Format("U8中采购入库单:{0} 已审核,不允许删除!", entity.cCode);
                    success = 0;
                }
                else
                {
                    //执行删除采购入库单操作
                    DeleteRdRecord01(entity.cCode);
                    msg     = string.Format("U8中采购入库单:{0} 已删除!", entity.cCode);
                    success = 1;
                }
            }
            else
            {
                msg = string.Format("U8中采购入库单:{0} 不存在!", entity.cCode);
            }
            return(msg);
        }
Exemple #2
0
        /// <summary>
        /// 新增采购入库单
        /// </summary>
        /// <param name="UserCode"></param>
        /// <param name="PlainPassword"></param>
        /// <param name="StrAccID"></param>
        /// <param name="AccYear"></param>
        /// <param name="Act"></param>
        /// <param name="kind"> 0:采购入库单;1:红字采购入库单</param>
        /// <param name="entity"></param>
        /// <param name="success"></param>
        /// <returns></returns>
        public string AddRdRecord01(string UserCode, string PlainPassword,
                                    string StrAccID, int AccYear, string Act, int kind, EntityRdRecord01Head entity, out int success)
        {
            success = 0;
            RdRecord01Bll bll = new RdRecord01Bll(StrAccID, AccYear, UserCode, PlainPassword);

            #region 验证
            string msg = "";
            if (!entity.CheckEntity(out msg))
            {
                return(msg);
            }
            foreach (Entityrdrecords01Body entitybody in entity.Details)
            {
                if (!entitybody.CheckEntity(out msg))
                {
                    return(msg);
                }
            }

            if (bll.GetGlmendFlag(entity.dDate.Year, entity.dDate.Month, "bflag_ST") == true)
            {
                return(string.Format("U8单据{0}日期所在月份已经结账!", entity.cCode));
            }
            //供应商
            if (!string.IsNullOrEmpty(entity.cVenCode))
            {
                string vendorname = bll.GetVendorName(entity.cVenCode);
                if (string.IsNullOrEmpty(vendorname))
                {
                    return(string.Format("U8中不存在供应商编码:{0}!", entity.cVenCode));
                }
            }

            // 仓库
            string warehouseName = bll.GetWarehouseName(entity.cWhCode);
            if (string.IsNullOrWhiteSpace(warehouseName))
            {
                return(string.Format("U8中不存在仓库编码:{0}!!", entity.cWhCode));
            }
            //采购类型
            List <EntityPurchaseType> purchasetype = bll.GetPurchaseType();
            if (purchasetype.Count(p => p.cPTCode == entity.cPTCode) == 0)
            {
                return(string.Format("U8中不存在采购类型编码:{0}!!", entity.cPTCode));
            }

            if (GetRdRecord01(entity.cCode) != 0)
            {
                return(string.Format("U8中已存在该入库单号{0}!", entity.cCode));
            }
            #endregion
            #region 表头
            //entity.ID = 1;//收发记录主表标识
            entity.bRdFlag    = 1;                                                                 //收发标志
            entity.cVouchType = "01";                                                              //单据类型编码
            entity.cBusType   = "普通采购";                                                            //业务类型
            entity.cSource    = string.IsNullOrWhiteSpace(entity.cOrderCode) ? "库存" : "采购订单";      //单据来源
            entity.cRdCode    = string.IsNullOrWhiteSpace(entity.cRdCode) ? "02" : entity.cRdCode; //收发类别编码

            // 收发类别编码
            if (string.IsNullOrWhiteSpace(bll.GetRdStyleName(entity.cRdCode, 1)))
            {
                return(string.Format("U8中不存在入库类别编码:{0}!", entity.cRdCode));
            }

            entity.bTransFlag  = 0;                                                     //是否传递
            entity.cMaker      = string.IsNullOrWhiteSpace(entity.cMaker) ? bll.GetUserName(UserCode) : entity.cMaker;
            entity.VT_ID       = 27;                                                    //单据模板号
            entity.bIsSTQc     = 0;                                                     //库存期初标志
            entity.iExchRate   = 1;                                                     //汇率
            entity.cExch_Name  = entity.cExch_Name == null ? "人民币" : entity.cExch_Name; //币种名称
            entity.cMemo       = entity.cMemo == null ? "" : entity.cMemo;              //备注
            entity.cSysbarCode = "||st01|" + entity.cCode;

            #endregion

            #region 表体
            foreach (Entityrdrecords01Body body in entity.Details)
            {
                // 存货编号
                string invName = GetInventoryName(body.cInvCode);
                if (string.IsNullOrWhiteSpace(invName))
                {
                    return(string.Format("U8中不存在存货编码:{0}!", body.cInvCode));
                }
                if (!string.IsNullOrWhiteSpace(body.cBatch) && bll.GetInventoryName(body.cInvCode, 4) == "0")
                {
                    return(string.Format("U8中存货编码:{0}未启用批次管理,批次信息必须为空!", body.cInvCode));
                }
                if (string.IsNullOrWhiteSpace(body.cBatch) && bll.GetInventoryName(body.cInvCode, 4) == "1")
                {
                    return(string.Format("U8中存货编码:{0}启用批次管理,批次信息不能为空!", body.cInvCode));
                }
                ;
                int bInvType = GetbInvType(body.cInvCode);
                if (bInvType == 1)
                {
                    body.iQuantity = 0;
                }

                if (kind == 0 && body.iQuantity <= 0 && bInvType == 0)
                {
                    return(string.Format("采购入库单入库数量不能小于或等于0!"));
                }

                if (kind == 1 && body.iQuantity >= 0 && bInvType == 0)
                {
                    return(string.Format("红字采购入库单入库数量不能大于或等于0!"));
                }
                //金额验证
                if (bInvType == 0 && Math.Round(body.ioriSum / body.iQuantity, 2, MidpointRounding.AwayFromZero) != Math.Round(body.iOriTaxCost, 2))
                {
                    return(string.Format("存货编码:{0}金额异常!", body.cInvCode));
                }

                body.iUnitCost        = Math.Round(body.iOriTaxCost / (1 + body.iTaxRate / 100), 2, MidpointRounding.AwayFromZero); //单价(原币无税单价)
                body.iPrice           = Math.Round(body.ioriSum / (1 + body.iTaxRate / 100), 2, MidpointRounding.AwayFromZero);     //金额(无税金额)
                body.iAPrice          = body.iPrice;                                                                                //暂估金额
                body.iFlag            = 0;                                                                                          //标志
                body.fACost           = body.iUnitCost;                                                                             //暂估单价
                body.chVencode        = entity.cVenCode;                                                                            //表头供应商
                body.iOriCost         = body.iUnitCost;                                                                             //原币无税单价
                body.iOriMoney        = body.iPrice;                                                                                //原币无税金额
                body.iOriTaxPrice     = body.ioriSum - body.iPrice;                                                                 //原币税额
                body.iTaxPrice        = body.iOriTaxPrice;                                                                          //本币税额
                body.iSum             = body.ioriSum;                                                                               //本币价税合计
                body.iBillSettleCount = 0;                                                                                          //单据结算次数
                body.iMatSettleState  = 0;                                                                                          //结算状态
                entity.iTaxRate       = body.iTaxRate;
                body.bCosting         = 1;
            }
            #endregion
            string id = bll.InsertRdRecord01(entity);
            success = string.IsNullOrWhiteSpace(id) ? 0 : 1;
            return(id);
        }