Esempio n. 1
0
        public int AddTransfer(Transfer Tf, Transferdetail[] tfd)
        {
            Transfer Transfer = new Transfer();

            Transfer.Id             = Tf.Id;
            Transfer.InBranchId     = Tf.InBranchId;
            Transfer.InStoreId      = Tf.InStoreId;
            Transfer.InStoreUserId  = Tf.InStoreUserId;
            Transfer.IsInner        = Tf.IsInner;
            Transfer.Memo           = Tf.Memo;
            Transfer.OutBranchId    = Tf.OutBranchId;
            Transfer.OutStoreId     = Tf.OutStoreId;
            Transfer.OutStoreUserId = Tf.OutStoreUserId;
            Transfer.Status         = Tf.Status;
            int TransferId = Transfer.Save();

            if (TransferId > 0)
            {
                foreach (Transferdetail t in tfd)
                {
                    Transferdetail tfdetail = new Transferdetail();
                    tfdetail.TransferId = TransferId;
                    tfdetail.GoodsId    = t.GoodsId;
                    tfdetail.Model      = t.Model;
                    tfdetail.Unit       = t.Unit;
                    tfdetail.AC         = t.AC;
                    tfdetail.Num        = t.Num;
                    tfdetail.Amount     = t.Amount;
                    tfdetail.Memo       = t.Memo;
                    tfdetail.UpdateDate = t.UpdateDate;
                    tfdetail.Save();
                }
            }
            return(TransferId);
        }
Esempio n. 2
0
        /// <summary>
        /// 调拨出库
        /// </summary>
        /// <param name="TransferId"></param>
        /// <param name="storeId"></param>
        /// <param name="UserId"></param>
        /// <returns></returns>
        public bool OutBoundT(int TransferId, int storeId, int UserId)
        {
            if (!IsTransferCanOutBound(TransferId, storeId))
            {
                return(false);
            }
            //  修改订单状态

            string sql = string.Format(" update Transfer set Status='调拨出库',OutStoreDate='{0}' where Id={1} ", DateTime.Now.ToString(), TransferId);

            if (m_dbo.ExecuteNonQuery(sql))
            {
                GoodsStoreManager gsm = new GoodsStoreManager();
                DataSet           ds  = ReadTransferDetail(TransferId);
                //读取商品明细
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    //循环单个商品
                    int goodsId          = DBTool.GetIntFromRow(row, "GoodsId", 0);
                    int num              = DBTool.GetIntFromRow(row, "Num", 0);
                    int Id               = DBTool.GetIntFromRow(row, "Id", 0);
                    GoodsStoreDetail gsd = new GoodsStoreDetail();
                    gsd.GoodsId    = goodsId;
                    gsd.Num        = num;
                    gsd.Operate    = CommenClass.TransferStatus.调拨出库.ToString();
                    gsd.RelationId = TransferId;
                    gsd.StoreId    = storeId;
                    gsd.UserId     = UserId;
                    double AC = gsm.OutBoundGoods(gsd);
                    if (AC > 0)
                    {
                        Transferdetail tfd = new Transferdetail();
                        tfd.Id = Id;
                        tfd.Load();
                        tfd.AC = AC;
                        tfd.Save();
                    }
                }
            }
            return(true);
        }
Esempio n. 3
0
        public bool ModifyTransfer(Transfer Tf, Transferdetail[] tfd)
        {
            Transfer Transfer = new Transfer();

            Transfer.Id = Tf.Id;
            Transfer.Load();
            Transfer.InBranchId     = Tf.InBranchId;
            Transfer.InStoreId      = Tf.InStoreId;
            Transfer.InStoreUserId  = Tf.InStoreUserId;
            Transfer.IsInner        = Tf.IsInner;
            Transfer.Memo           = Tf.Memo;
            Transfer.OutStoreId     = Tf.OutStoreId;
            Transfer.OutStoreUserId = Tf.OutStoreUserId;
            Transfer.Status         = Tf.Status;
            Transfer.UpdateDate     = DateTime.Now;
            int TransferId = Transfer.Save();

            if (TransferId > 0)
            {
                DataTable dtOld = this.ReadTransferDetail(TransferId).Tables[0];
                for (int i = 0; i < tfd.Length; i++)
                {
                    DataRow[] rows = dtOld.Select(string.Format(" GoodsId={0} ", tfd[i].GoodsId));
                    if (rows.Length == 1)//有这个商品
                    {
                        int    oldNum  = DBTool.GetIntFromRow(rows[0], "num", 0);
                        string oldMemo = DBTool.GetStringFromRow(rows[0], "Memo", "");
                        if (tfd[i].Num != oldNum || tfd[i].Memo != oldMemo)//有变化需要修改
                        {
                            Transferdetail od = new Transferdetail();
                            od.Id = DBTool.GetIntFromRow(rows[0], "Id", 0);
                            od.Load();
                            od.Num    = tfd[i].Num;
                            od.Amount = tfd[i].Num * tfd[i].AC;
                            od.Memo   = tfd[i].Memo.Replace(" ", "").Replace("  ", "");
                            od.Save();
                        }
                    }
                    else //新增商品
                    {
                        Transferdetail od = new Transferdetail();
                        od.GoodsId    = tfd[i].GoodsId;
                        od.TransferId = TransferId;
                        od.Model      = tfd[i].Model;
                        od.Unit       = tfd[i].Unit;
                        od.AC         = tfd[i].AC;
                        od.Num        = tfd[i].Num;
                        od.Amount     = tfd[i].Amount;
                        od.Memo       = tfd[i].Memo;
                        od.UpdateDate = DateTime.Now;
                        od.Save();
                    }
                }

                //循环旧表,查找新表中没有的项。删除,记录明细
                foreach (DataRow row in dtOld.Select(""))
                {
                    int  goodsId  = DBTool.GetIntFromRow(row, "goodsId", 0);
                    int  oldnum   = DBTool.GetIntFromRow(row, "num", 0);
                    bool isExsist = false;
                    for (int i = 0; i < tfd.Length; i++)
                    {
                        if (tfd[i].GoodsId == goodsId)
                        {
                            isExsist = true;
                            break;
                        }
                    }
                    if (isExsist == false)
                    {
                        //新订单中无 此项
                        int            odId = DBTool.GetIntFromRow(row, "Id", 0);
                        Transferdetail od   = new Transferdetail();
                        od.Id      = odId;
                        od.GoodsId = goodsId;
                        od.Delete();
                    }
                }
            }
            return(true);
        }