Ejemplo n.º 1
0
        public static string UpdateOcDetails(OrderDetails model)
        {
            string result = "";
            string strSql = "";
            string Seq    = GenNumberDAL.GetOcDetailsSeq("oc_OrderDetails", model.OcID);

            strSql = "Insert Into oc_OrderDetails (OcID,Seq,ProductMo,ProductID,OrderQty,OrderUnit,Price,PriceUnit) Values ('"
                     + model.OcID + "','" + Seq + "','" + model.ProductMo + "','" + model.ProductID + "','" + model.OrderQty
                     + "','" + model.OrderUnit + "','" + model.Price + "','" + model.PriceUnit + "')";
            result = SQLHelper.ExecuteSqlUpdate(strSql);
            return(result);
        }
Ejemplo n.º 2
0
        public static UpdateStatusModels UpdateTransferDetails(TransferDetails model)
        {
            string             result    = "";
            bool               ValidFlag = true;
            string             strSql    = "";
            string             ID        = model.ID;
            string             LocID     = model.LocID;
            string             NextLocID = model.NextLocID;
            string             QtyUnit   = model.QtyUnit;
            string             WegUnit   = model.WegUnit;
            UpdateStatusModels resModel  = new UpdateStatusModels();
            DataTable          dtFlag    = BaseDataDAL.GetDocFlayReturnTable("wh_transfer", model.FlagID);
            string             flag0     = dtFlag.Rows[0]["flag0"].ToString().Trim();
            string             flag1     = dtFlag.Rows[0]["flag1"].ToString().Trim();
            string             flag2     = dtFlag.Rows[0]["flag2"].ToString().Trim();

            strSql += string.Format(@" SET XACT_ABORT  ON ");
            strSql += string.Format(@" BEGIN TRANSACTION ");
            bool FirstRec = false;

            if (ID == null || ID == "")
            {
                FirstRec = true;
                ID       = GenNumberDAL.GenTransferID(flag0, LocID, NextLocID, flag2);
            }
            else
            {
                if (!CheckTransferHead(ID))
                {
                    FirstRec = true;
                    ID       = GenNumberDAL.GenTransferID(flag0, LocID, NextLocID, flag2);
                }
            }
            if (FirstRec)
            {
                strSql += string.Format(@"Insert Into wm_TransferHead (ID,TransferDate,LocID,NextLocID,FlagID) Values ('"
                                        + ID + "','" + model.TransferDate + "','" + model.LocID + "','" + model.NextLocID + "','" + model.FlagID + "')");
            }
            else
            {
                strSql += string.Format(@"UPDATE wm_TransferHead SET TransferDate='{0}' WHERE ID='{1}'"
                                        , model.TransferDate, ID);
            }

            string  ProductMo = model.ProductMo;
            string  GoodsID   = model.GoodsID;
            string  LotNo     = model.LotNo;
            decimal Qty       = model.TransferQty.ToString().Trim() != "" ? model.TransferQty : 0;
            decimal Weg       = model.TransferWeg.ToString().Trim() != "" ? model.TransferWeg : 0;

            result = CheckQtyStore(LocID, GoodsID, ProductMo, LotNo, flag1, Weg, Qty);
            if (result != "")
            {
                ValidFlag = false;
            }
            else
            {
                if (flag2 == "TO")
                {
                    result = CheckQtyStore(NextLocID, GoodsID, ProductMo, LotNo, "+", Weg, Qty);
                    if (result != "")
                    {
                        ValidFlag = false;
                    }
                }
            }
            if (ValidFlag == false)
            {
                resModel.Msg = result;
                return(resModel);
            }

            string Seq        = GenNumberDAL.GetDetailsSeq("wm_TransferDetails", model.ID);
            string CreateUser = "";
            string CreateTime = System.DateTime.Now.ToString("yyyy/MM/dd HH:ss:mm");

            strSql += string.Format(@"Insert Into wm_TransferDetails (ID,Seq,ProductMo,GoodsID,LocID,LotNo,TransferQty,TransferWeg,QtyUnit,WegUnit,NextLocID,CreateUser,CreateTime) Values " +
                                    "('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}')"
                                    , ID, Seq, model.ProductMo, model.GoodsID, model.LocID, model.LotNo, model.TransferQty, model.TransferWeg, QtyUnit, WegUnit, NextLocID, "", CreateTime);
            strSql += string.Format(JoinUpdateStr("U", LocID, GoodsID, ProductMo, LotNo, flag1, Weg, Qty, CreateUser, CreateTime));
            if (flag2 == "TO")
            {
                strSql += string.Format(JoinUpdateStr("U", NextLocID, GoodsID, ProductMo, LotNo, "+", Weg, Qty, CreateUser, CreateTime));
            }
            strSql += string.Format(@" COMMIT TRANSACTION ");
            result  = SQLHelper.ExecuteSqlUpdate(strSql);
            if (result == "")
            {
                resModel.Status = "OK";
            }
            else
            {
                resModel.Status = "ERROR";
                resModel.Msg    = result;
            }
            resModel.ReturnValue = ID;
            return(resModel);
        }