public static string GetProductLoid(string Barcode) { ProductDAL pDAL = new ProductDAL(); pDAL.GetDataByBarCode(Barcode, null); return pDAL.PRODUCTMASTER.ToString(); }
public static string GetProductName(string Barcode) { ProductDAL pDAL = new ProductDAL(); pDAL.GetDataByBarCode(Barcode, null); return pDAL.NAME; }
public bool UpdateData(string userID, PlanPopupData data) { bool ret = true; double leadtimePO = 0; double leadtimePD = 0; double produceLOID = 0; double purchaseLOID = 0; OracleDBObj obj = new OracleDBObj(); obj.CreateConnection(); obj.CreateTransaction(); try { PlanProduceDAL produceDAL = new PlanProduceDAL(); PlanPurchaseDAL purchaseDAL = new PlanPurchaseDAL(); PlanReceiveDAL receiveDAL = new PlanReceiveDAL(); PlanReceiveItemDAL receiveItemDAL = new PlanReceiveItemDAL(); DALObj.OnDB = false; DALObj.GetDataByLOID(data.PLAN, obj.zTrans); if (DALObj.STATUS == Constz.Requisition.Status.Waiting.Code) { #region PlanReceive receiveDAL.GetDataByLOID(data.RECEIVELOID, obj.zTrans); switch (data.DAY.ToString()) { case "1": receiveDAL.DAY1 = data.PDQTY + data.POQTY; break; case "2": receiveDAL.DAY2 = data.PDQTY + data.POQTY; break; case "3": receiveDAL.DAY3 = data.PDQTY + data.POQTY; break; case "4": receiveDAL.DAY4 = data.PDQTY + data.POQTY; break; case "5": receiveDAL.DAY5 = data.PDQTY + data.POQTY; break; case "6": receiveDAL.DAY6 = data.PDQTY + data.POQTY; break; case "7": receiveDAL.DAY7 = data.PDQTY + data.POQTY; break; case "8": receiveDAL.DAY8 = data.PDQTY + data.POQTY; break; case "9": receiveDAL.DAY9 = data.PDQTY + data.POQTY; break; case "10": receiveDAL.DAY10 = data.PDQTY + data.POQTY; break; case "11": receiveDAL.DAY11 = data.PDQTY + data.POQTY; break; case "12": receiveDAL.DAY12 = data.PDQTY + data.POQTY; break; case "13": receiveDAL.DAY13 = data.PDQTY + data.POQTY; break; case "14": receiveDAL.DAY14 = data.PDQTY + data.POQTY; break; case "15": receiveDAL.DAY15 = data.PDQTY + data.POQTY; break; case "16": receiveDAL.DAY16 = data.PDQTY + data.POQTY; break; case "17": receiveDAL.DAY17 = data.PDQTY + data.POQTY; break; case "18": receiveDAL.DAY18 = data.PDQTY + data.POQTY; break; case "19": receiveDAL.DAY19 = data.PDQTY + data.POQTY; break; case "20": receiveDAL.DAY20 = data.PDQTY + data.POQTY; break; case "21": receiveDAL.DAY21 = data.PDQTY + data.POQTY; break; case "22": receiveDAL.DAY22 = data.PDQTY + data.POQTY; break; case "23": receiveDAL.DAY23 = data.PDQTY + data.POQTY; break; case "24": receiveDAL.DAY24 = data.PDQTY + data.POQTY; break; case "25": receiveDAL.DAY25 = data.PDQTY + data.POQTY; break; case "26": receiveDAL.DAY26 = data.PDQTY + data.POQTY; break; case "27": receiveDAL.DAY27 = data.PDQTY + data.POQTY; break; case "28": receiveDAL.DAY28 = data.PDQTY + data.POQTY; break; case "29": receiveDAL.DAY29 = data.PDQTY + data.POQTY; break; case "30": receiveDAL.DAY30 = data.PDQTY + data.POQTY; break; case "31": receiveDAL.DAY31 = data.PDQTY + data.POQTY; break; } ret = receiveDAL.UpdateCurrentData(userID, obj.zTrans); if (!ret) throw new ApplicationException(receiveDAL.ErrorMessage); #endregion ProductDAL pDAL = new ProductDAL(); pDAL.GetDataByLOID(receiveDAL.PRODUCT, obj.zTrans); leadtimePO = pDAL.LEADTIME; leadtimePD = pDAL.LEADTIMEPD; DateTime purchaseDate = new DateTime(Convert.ToInt32(DALObj.YEAR) - 543, Convert.ToInt32(receiveDAL.MONTH), data.DAY).AddDays(-leadtimePO); DateTime produceDate = new DateTime(Convert.ToInt32(DALObj.YEAR) - 543, Convert.ToInt32(receiveDAL.MONTH), data.DAY).AddDays(-leadtimePD); #region PlanPurchase purchaseDAL.GetData(DALObj.LOID, purchaseDate.Month, receiveDAL.PRODUCT, DALObj.STATUS, obj.zTrans); switch (purchaseDate.Day.ToString()) { case "1": purchaseDAL.DAY1 = data.POQTY; break; case "2": purchaseDAL.DAY2 = data.POQTY; break; case "3": purchaseDAL.DAY3 = data.POQTY; break; case "4": purchaseDAL.DAY4 = data.POQTY; break; case "5": purchaseDAL.DAY5 = data.POQTY; break; case "6": purchaseDAL.DAY6 = data.POQTY; break; case "7": purchaseDAL.DAY7 = data.POQTY; break; case "8": purchaseDAL.DAY8 = data.POQTY; break; case "9": purchaseDAL.DAY9 = data.POQTY; break; case "10": purchaseDAL.DAY10 = data.POQTY; break; case "11": purchaseDAL.DAY11 = data.POQTY; break; case "12": purchaseDAL.DAY12 = data.POQTY; break; case "13": purchaseDAL.DAY13 = data.POQTY; break; case "14": purchaseDAL.DAY14 = data.POQTY; break; case "15": purchaseDAL.DAY15 = data.POQTY; break; case "16": purchaseDAL.DAY16 = data.POQTY; break; case "17": purchaseDAL.DAY17 = data.POQTY; break; case "18": purchaseDAL.DAY18 = data.POQTY; break; case "19": purchaseDAL.DAY19 = data.POQTY; break; case "20": purchaseDAL.DAY20 = data.POQTY; break; case "21": purchaseDAL.DAY21 = data.POQTY; break; case "22": purchaseDAL.DAY22 = data.POQTY; break; case "23": purchaseDAL.DAY23 = data.POQTY; break; case "24": purchaseDAL.DAY24 = data.POQTY; break; case "25": purchaseDAL.DAY25 = data.POQTY; break; case "26": purchaseDAL.DAY26 = data.POQTY; break; case "27": purchaseDAL.DAY27 = data.POQTY; break; case "28": purchaseDAL.DAY28 = data.POQTY; break; case "29": purchaseDAL.DAY29 = data.POQTY; break; case "30": purchaseDAL.DAY30 = data.POQTY; break; case "31": purchaseDAL.DAY31 = data.POQTY; break; } ret = purchaseDAL.UpdateCurrentData(userID, obj.zTrans); if (!ret) throw new ApplicationException(purchaseDAL.ErrorMessage); purchaseLOID = purchaseDAL.LOID; #endregion #region PlanProduce produceDAL.GetData(DALObj.LOID, produceDate.Month, receiveDAL.PRODUCT, DALObj.STATUS, obj.zTrans); switch (produceDate.Day.ToString()) { case "1": produceDAL.DAY1 = data.PDQTY; break; case "2": produceDAL.DAY2 = data.PDQTY; break; case "3": produceDAL.DAY3 = data.PDQTY; break; case "4": produceDAL.DAY4 = data.PDQTY; break; case "5": produceDAL.DAY5 = data.PDQTY; break; case "6": produceDAL.DAY6 = data.PDQTY; break; case "7": produceDAL.DAY7 = data.PDQTY; break; case "8": produceDAL.DAY8 = data.PDQTY; break; case "9": produceDAL.DAY9 = data.PDQTY; break; case "10": produceDAL.DAY10 = data.PDQTY; break; case "11": produceDAL.DAY11 = data.PDQTY; break; case "12": produceDAL.DAY12 = data.PDQTY; break; case "13": produceDAL.DAY13 = data.PDQTY; break; case "14": produceDAL.DAY14 = data.PDQTY; break; case "15": produceDAL.DAY15 = data.PDQTY; break; case "16": produceDAL.DAY16 = data.PDQTY; break; case "17": produceDAL.DAY17 = data.PDQTY; break; case "18": produceDAL.DAY18 = data.PDQTY; break; case "19": produceDAL.DAY19 = data.PDQTY; break; case "20": produceDAL.DAY20 = data.PDQTY; break; case "21": produceDAL.DAY21 = data.PDQTY; break; case "22": produceDAL.DAY22 = data.PDQTY; break; case "23": produceDAL.DAY23 = data.PDQTY; break; case "24": produceDAL.DAY24 = data.PDQTY; break; case "25": produceDAL.DAY25 = data.PDQTY; break; case "26": produceDAL.DAY26 = data.PDQTY; break; case "27": produceDAL.DAY27 = data.PDQTY; break; case "28": produceDAL.DAY28 = data.PDQTY; break; case "29": produceDAL.DAY29 = data.PDQTY; break; case "30": produceDAL.DAY30 = data.PDQTY; break; case "31": produceDAL.DAY31 = data.PDQTY; break; } ret = produceDAL.UpdateCurrentData(userID, obj.zTrans); if (!ret) throw new ApplicationException(produceDAL.ErrorMessage); produceLOID = produceDAL.LOID; #endregion receiveItemDAL.GetData(data.PLAN, receiveDAL.PRODUCT, new DateTime(Convert.ToInt32(DALObj.YEAR) - 543, Convert.ToInt32(receiveDAL.MONTH), data.DAY), obj.zTrans); if (receiveItemDAL.OnDB) { if (receiveItemDAL.PODATE != purchaseDate) { #region PlanPurchase purchaseDAL.OnDB = false; purchaseDAL.GetData(DALObj.LOID, receiveItemDAL.PODATE.Month, receiveDAL.PRODUCT, DALObj.STATUS, obj.zTrans); switch (receiveItemDAL.PODATE.Day.ToString()) { case "1": purchaseDAL.DAY1 = 0; break; case "2": purchaseDAL.DAY2 = 0; break; case "3": purchaseDAL.DAY3 = 0; break; case "4": purchaseDAL.DAY4 = 0; break; case "5": purchaseDAL.DAY5 = 0; break; case "6": purchaseDAL.DAY6 = 0; break; case "7": purchaseDAL.DAY7 = 0; break; case "8": purchaseDAL.DAY8 = 0; break; case "9": purchaseDAL.DAY9 = 0; break; case "10": purchaseDAL.DAY10 = 0; break; case "11": purchaseDAL.DAY11 = 0; break; case "12": purchaseDAL.DAY12 = 0; break; case "13": purchaseDAL.DAY13 = 0; break; case "14": purchaseDAL.DAY14 = 0; break; case "15": purchaseDAL.DAY15 = 0; break; case "16": purchaseDAL.DAY16 = 0; break; case "17": purchaseDAL.DAY17 = 0; break; case "18": purchaseDAL.DAY18 = 0; break; case "19": purchaseDAL.DAY19 = 0; break; case "20": purchaseDAL.DAY20 = 0; break; case "21": purchaseDAL.DAY21 = 0; break; case "22": purchaseDAL.DAY22 = 0; break; case "23": purchaseDAL.DAY23 = 0; break; case "24": purchaseDAL.DAY24 = 0; break; case "25": purchaseDAL.DAY25 = 0; break; case "26": purchaseDAL.DAY26 = 0; break; case "27": purchaseDAL.DAY27 = 0; break; case "28": purchaseDAL.DAY28 = 0; break; case "29": purchaseDAL.DAY29 = 0; break; case "30": purchaseDAL.DAY30 = 0; break; case "31": purchaseDAL.DAY31 = 0; break; } if (purchaseDAL.OnDB) { ret = purchaseDAL.UpdateCurrentData(userID, obj.zTrans); if (!ret) throw new ApplicationException(purchaseDAL.ErrorMessage); } #endregion } if (receiveItemDAL.PDDATE != produceDate) { #region PlanProduce produceDAL.OnDB = false; produceDAL.GetData(DALObj.LOID, receiveItemDAL.PDDATE.Month, receiveDAL.PRODUCT, DALObj.STATUS, obj.zTrans); switch (receiveItemDAL.PDDATE.Day.ToString()) { case "1": produceDAL.DAY1 = 0; break; case "2": produceDAL.DAY2 = 0; break; case "3": produceDAL.DAY3 = 0; break; case "4": produceDAL.DAY4 = 0; break; case "5": produceDAL.DAY5 = 0; break; case "6": produceDAL.DAY6 = 0; break; case "7": produceDAL.DAY7 = 0; break; case "8": produceDAL.DAY8 = 0; break; case "9": produceDAL.DAY9 = 0; break; case "10": produceDAL.DAY10 = 0; break; case "11": produceDAL.DAY11 = 0; break; case "12": produceDAL.DAY12 = 0; break; case "13": produceDAL.DAY13 = 0; break; case "14": produceDAL.DAY14 = 0; break; case "15": produceDAL.DAY15 = 0; break; case "16": produceDAL.DAY16 = 0; break; case "17": produceDAL.DAY17 = 0; break; case "18": produceDAL.DAY18 = 0; break; case "19": produceDAL.DAY19 = 0; break; case "20": produceDAL.DAY20 = 0; break; case "21": produceDAL.DAY21 = 0; break; case "22": produceDAL.DAY22 = 0; break; case "23": produceDAL.DAY23 = 0; break; case "24": produceDAL.DAY24 = 0; break; case "25": produceDAL.DAY25 = 0; break; case "26": produceDAL.DAY26 = 0; break; case "27": produceDAL.DAY27 = 0; break; case "28": produceDAL.DAY28 = 0; break; case "29": produceDAL.DAY29 = 0; break; case "30": produceDAL.DAY30 = 0; break; case "31": produceDAL.DAY31 = 0; break; } if (produceDAL.OnDB) { ret = produceDAL.UpdateCurrentData(userID, obj.zTrans); if (!ret) throw new ApplicationException(produceDAL.ErrorMessage); } #endregion } } receiveItemDAL.PDDATE = produceDate; receiveItemDAL.PLAN = data.PLAN; receiveItemDAL.PODATE = purchaseDate; receiveItemDAL.PRODUCT = receiveDAL.PRODUCT; receiveItemDAL.PRODUCTMASTER = receiveDAL.PRODUCTMASTER; receiveItemDAL.RECEIVEDATE = new DateTime(Convert.ToInt32(DALObj.YEAR) - 543, Convert.ToInt32(receiveDAL.MONTH), data.DAY); receiveItemDAL.STATUS = DALObj.STATUS; receiveItemDAL.UNIT = receiveDAL.UNIT; receiveItemDAL.POLOID = purchaseLOID; receiveItemDAL.PDLOID = produceLOID; receiveItemDAL.POQTY = data.POQTY; receiveItemDAL.PDQTY = data.PDQTY; if (receiveItemDAL.OnDB) { if (data.PDQTY == 0 && data.POQTY == 0) ret = receiveItemDAL.DeleteCurrentData(obj.zTrans); else ret = receiveItemDAL.UpdateCurrentData(userID, obj.zTrans); } else ret = receiveItemDAL.InsertCurrentData(userID, obj.zTrans); if (!ret) throw new ApplicationException(receiveItemDAL.ErrorMessage); ret = DALObj.CalculateWHPlanRemainByProduct(userID, DALObj.LOID, purchaseDAL.PRODUCT, purchaseDAL.PRODUCTMASTER, obj.zTrans); if (!ret) throw new ApplicationException(DALObj.ErrorMessage); } obj.zTrans.Commit(); obj.CloseConnection(); } catch (Exception ex) { obj.zTrans.Rollback(); obj.CloseConnection(); ret = false; _error = ex.Message; } return ret; }
private bool AddProduct(double plan, string userID, string where) { ProductDAL pDAL = new ProductDAL(); bool ret = true; OracleDBObj obj = new OracleDBObj(); obj.CreateConnection(); obj.CreateTransaction(); try { DataTable dtProduct = SaleDAL.GetProductPlanList(where, obj.zTrans); foreach (DataRow dRow in dtProduct.Rows) { DALItemObj.OnDB = false; DALItemObj.PLAN = plan; DALItemObj.PRODUCT = Convert.ToDouble(dRow["LOID"]); DALItemObj.STATUS = Constz.Requisition.Status.Waiting.Code; DALItemObj.UNIT = Convert.ToDouble(dRow["UNIT"]); DALItemObj.PRODUCTMASTER = Convert.ToDouble(dRow["PRODUCTMASTER"]); ret = DALItemObj.InsertCurrentData(userID, obj.zTrans); if (!ret) { _error = DALItemObj.ErrorMessage; break; } } if (ret) { obj.zTrans.Commit(); obj.CloseConnection(); } } catch (Exception ex) { obj.zTrans.Rollback(); obj.CloseConnection(); ret = false; _error = ex.Message; } return ret; }
public static string GetLotNo(string userID, double productLOID, OracleTransaction zTrans) { bool LetClose = false; string code = ""; OracleConnection zConn = null; if (zTrans == null) { LetClose = true; zConn = OracleDB.GetConnection(); zTrans = zConn.BeginTransaction(IsolationLevel.ReadCommitted); } ProductDAL _dal = new ProductDAL(); if (_dal.GetDataByLOID(productLOID, zTrans)) { if (_dal.YEAR == (DateTime.Now.Year + 543).ToString().Substring(2)) { if (_dal.RUNNING == "9") { _dal.RUNNING = "1"; switch (_dal.LOTNO) { case "A": _dal.LOTNO = "B"; break; case "B": _dal.LOTNO = "C"; break; case "C": _dal.LOTNO = "D"; break; case "D": _dal.LOTNO = "E"; break; case "E": _dal.LOTNO = "F"; break; case "F": _dal.LOTNO = "G"; break; case "G": _dal.LOTNO = "H"; break; case "H": _dal.LOTNO = "I"; break; case "I": _dal.LOTNO = "J"; break; case "J": _dal.LOTNO = "K"; break; case "K": _dal.LOTNO = "L"; break; case "L": _dal.LOTNO = "M"; break; case "M": _dal.LOTNO = "N"; break; case "N": _dal.LOTNO = "O"; break; case "O": _dal.LOTNO = "P"; break; case "P": _dal.LOTNO = "Q"; break; case "Q": _dal.LOTNO = "R"; break; case "R": _dal.LOTNO = "S"; break; case "S": _dal.LOTNO = "T"; break; case "T": _dal.LOTNO = "U"; break; case "U": _dal.LOTNO = "V"; break; case "V": _dal.LOTNO = "W"; break; case "W": _dal.LOTNO = "X"; break; case "X": _dal.LOTNO = "Y"; break; case "Y": _dal.LOTNO = "Z"; break; case "Z": _dal.LOTNO = "A"; break; default: _dal.LOTNO = "A"; break; } } else { _dal.RUNNING = (Convert.ToInt32(_dal.RUNNING == "" ? "0" : _dal.RUNNING) + 1).ToString().Trim(); } } else { _dal.LOTNO = "A"; _dal.RUNNING = "1"; _dal.YEAR = (DateTime.Now.Year + 543).ToString().Substring(2); } if (!_dal.UpdateCurrentData(userID, zTrans)) { if (LetClose) { zTrans.Commit(); zConn.Close(); } throw new ApplicationException(_dal.ErrorMessage); } else { code = (_dal.CODE.Length > 3 ? _dal.CODE.Substring(0, 3) : _dal.CODE) + " " + _dal.LOTNO + _dal.RUNNING + _dal.YEAR; } } else { if (LetClose) { zTrans.Commit(); zConn.Close(); } throw new ApplicationException("ДаХйрарц╤мХр╧╓Хр running йскця╨ lotno Д╢И"); } if (LetClose) { zTrans.Commit(); zConn.Close(); } return code; }