public ActionResult GetDocFlagReturnString(string ID) { DataTable dt = BaseDataDAL.GetDocFlayReturnTable("wh_transfer", ID); var val = dt.Rows[0]["flag2"].ToString().Trim(); return(Json(val, JsonRequestBehavior.AllowGet)); }
public static UpdateStatusModels Delete(string ID, string Seq) { string result = ""; UpdateStatusModels resModel = new UpdateStatusModels(); DataTable dtTransfer = FindDetailsByID(ID, Seq); DataRow dr = dtTransfer.Rows[0]; string FlagID = dr["FlagID"].ToString().Trim(); string ProductMo = dr["ProductMo"].ToString().Trim(); string GoodsID = dr["GoodsID"].ToString().Trim(); string LotNo = dr["LotNo"].ToString().Trim(); string LocID = dr["LocID"].ToString().Trim(); string NextLocID = dr["NextLocID"].ToString().Trim(); decimal Weg = 0 - (dr["TransferWeg"].ToString().Trim() != "" ? Convert.ToDecimal(dr["TransferWeg"].ToString().Trim()) : 0); decimal Qty = 0 - (dr["TransferQty"].ToString().Trim() != "" ? Convert.ToDecimal(dr["TransferQty"].ToString().Trim()) : 0); string CreateUser = ""; string CreateTime = System.DateTime.Now.ToString("yyyy/MM/dd HH:ss:mm"); DataTable dtFlag = BaseDataDAL.GetDocFlayReturnTable("wh_transfer", FlagID); string flag1 = dtFlag.Rows[0]["flag1"].ToString().Trim(); string flag2 = dtFlag.Rows[0]["flag2"].ToString().Trim(); bool valid_flag = true; result = CheckQtyStore(LocID, GoodsID, ProductMo, LotNo, flag1, Weg, Qty); if (result != "") { valid_flag = false; } else { if (flag2 == "TO") { result = CheckQtyStore(NextLocID, GoodsID, ProductMo, LotNo, "+", Weg, Qty); if (result != "") { valid_flag = false; } } } if (valid_flag == true) { string strSql = ""; strSql += string.Format(@" SET XACT_ABORT ON "); strSql += string.Format(@" BEGIN TRANSACTION "); strSql += string.Format(@"Delete From wm_TransferDetails Where ID='{0}' And Seq='{1}'", ID, Seq); strSql += string.Format(JoinUpdateStr("D", LocID, GoodsID, ProductMo, LotNo, flag1, Weg, Qty, CreateUser, CreateTime)); if (flag2 == "TO") { strSql += string.Format(JoinUpdateStr("D", 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); }
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); }