private ToDoListMinimumStockRequestData GetData() { ToDoListMinimumStockRequestData data = new ToDoListMinimumStockRequestData(); data.ACTIVE = Constz.ActiveStatus.Active; data.DIVISION = Authz.CurrentUserInfo.DivisionID; data.REQUESTBY = Authz.CurrentUserInfo.OfficerID; data.REQUISITIONTYPE = Constz.Requisition.RequisitionType.REQ07; data.STATUS = Constz.Requisition.Status.Waiting.Code; data.WAREHOUSE = Authz.CurrentUserInfo.Warehouse; for (int i = 0; i < this.grvRequisition.Rows.Count; ++i) { CheckBox chk = (CheckBox)this.grvRequisition.Rows[i].Cells[1].FindControl("chkItem"); if (chk.Checked && chk.Enabled && this.grvRequisition.Rows[i].Cells[1].CssClass != "zhidden") { if (data.ORDERTYPE == "") data.ORDERTYPE = this.grvRequisition.Rows[i].Cells[12].Text; else if (data.ORDERTYPE != this.grvRequisition.Rows[i].Cells[12].Text) throw new ApplicationException( "äÁèÊÒÁÒö·ÓÃÒ¡ÒÃä´é à¹×èͧ¨Ò¡äÁèãªè»ÃÐàÀ·¤ÓÊÑè§à´ÕÂǡѹ"); ToDoListMinimumStockRequestItemData itemData = new ToDoListMinimumStockRequestItemData(); itemData.PRODUCT = Convert.ToDouble(this.grvRequisition.Rows[i].Cells[0].Text); itemData.QTY = Convert.ToDouble(this.grvRequisition.Rows[i].Cells[9].Text); itemData.UNIT = Convert.ToDouble(this.grvRequisition.Rows[i].Cells[13].Text); data.ITEM.Add(itemData); } } return data; }
public bool NewPDDocument(string UserID, ToDoListMinimumStockRequestData data) { bool ret = true; ret = NewRequisition(UserID, data); return ret; }
private bool NewPDRequest(string UserID, ToDoListMinimumStockRequestData data) { bool ret = true; OracleDBObj obj = new OracleDBObj(); obj.CreateConnection(); obj.CreateTransaction(); try { PDRequestDAL _DAL = new PDRequestDAL(); _DAL.OnDB = false; _DAL.REQUESTDATE = DateTime.Now.Date; _DAL.ORDERTYPE = data.ORDERTYPE; _DAL.REQUESTBY = data.REQUESTBY; _DAL.DIVISION = data.DIVISION; _DAL.ACTIVE = data.ACTIVE; _DAL.STATUS = data.STATUS; //_DAL ret = _DAL.InsertCurrentData(UserID, obj.zTrans); if (!ret) { throw new ApplicationException(_DAL.ErrorMessage); } PRItemDAL _DALItem = new PRItemDAL(); for (int i = 0; i < data.ITEM.Count; ++i) { _DALItem.OnDB = false; ToDoListMinimumStockRequestItemData itemData = (ToDoListMinimumStockRequestItemData)data.ITEM[i]; _DALItem.PDREQUEST = _DAL.LOID; _DALItem.PRODUCT = itemData.PRODUCT; _DALItem.QTY = itemData.QTY; DataTable dt = GetProduct(itemData.PRODUCT); _DALItem.STATUS = data.STATUS; _DALItem.UNIT = Convert.ToDouble(dt.Rows[0]["UNIT"]); _DALItem.MINPRICE = Convert.ToDouble(dt.Rows[0]["MINPRICE"]); _DALItem.OLDPRICE = Convert.ToDouble(dt.Rows[0]["LASTPRICE"]); _DALItem.MINSTOCK = Convert.ToDouble(dt.Rows[0]["MIN"]); _DALItem.MAXSTOCK = Convert.ToDouble(dt.Rows[0]["MAX"]); _DALItem.STOCK = Convert.ToDouble(dt.Rows[0]["STOCK"]); _DALItem.LAST3MON = Convert.ToDouble(dt.Rows[0]["USED3MONTH"]); _DALItem.LASTYEAR = Convert.ToDouble(dt.Rows[0]["USED12MONTH"]); _DALItem.DUEDATE = Convert.ToDateTime(dt.Rows[0]["DUEDATE"]); ret = _DALItem.InsertCurrentData(UserID, obj.zTrans); if (!ret) { throw new ApplicationException(_DALItem.ErrorMessage); } } _LOID = _DAL.LOID; obj.zTrans.Commit(); obj.CloseConnection(); } catch (Exception ex) { obj.zTrans.Rollback(); obj.CloseConnection(); ret = false; _error = ex.Message; } return ret; }
private bool NewRequisition(string UserID, ToDoListMinimumStockRequestData data) { bool ret = true; OracleDBObj obj = new OracleDBObj(); obj.CreateConnection(); obj.CreateTransaction(); try { RequisitionDAL _DAL = new RequisitionDAL(); _DAL.OnDB = false; _DAL.OFFICER = data.REQUESTBY; _DAL.REQDATE = DateTime.Now.Date; _DAL.ACTIVE = data.ACTIVE; _DAL.STATUS = data.STATUS; _DAL.WAREHOUSE = data.WAREHOUSE; _DAL.REQUISITIONTYPE = data.REQUISITIONTYPE; _DAL.RESERVEDATE = DateTime.Now.Date; ret = _DAL.InsertCurrentData(UserID, obj.zTrans); if (!ret) { throw new ApplicationException(_DAL.ErrorMessage); } RequisitionItemDAL _DALItem = new RequisitionItemDAL(); for (int i = 0; i < data.ITEM.Count; ++i) { _DALItem.OnDB = false; ToDoListMinimumStockRequestItemData itemData = (ToDoListMinimumStockRequestItemData)data.ITEM[i]; _DALItem.ACTIVE = data.ACTIVE; _DALItem.PRODUCT = itemData.PRODUCT; _DALItem.QTY = itemData.QTY; _DALItem.REQUISITION = _DAL.LOID; _DALItem.UNIT = itemData.UNIT; _DALItem.DUEDATE = DateTime.Now.Date; ret = _DALItem.InsertCurrentData(UserID, obj.zTrans); if (!ret) { throw new ApplicationException(_DALItem.ErrorMessage); } } _LOID = _DAL.LOID; obj.zTrans.Commit(); obj.CloseConnection(); } catch (Exception ex) { obj.zTrans.Rollback(); obj.CloseConnection(); ret = false; _error = ex.Message; } return ret; }