public int Delete(Database database, ClassListDTO data) { Database db = UseDatabase(database); StringBuilder sb = new StringBuilder(); #region SQL Statement string tableName = EVOFramework.Data.DTOUtility.ReadTableName(typeof(ClassListDTO)); sb.AppendLine(" DELETE FROM " + tableName); sb.AppendLine(" WHERE "); sb.AppendLine(" " + ClassListDTO.eColumns.CLS_INFO_CD + "=:CLS_INFO_CD"); sb.AppendLine(" AND " + ClassListDTO.eColumns.CLS_CD + "=:CLS_CD"); sb.AppendLine(" AND " + ClassListDTO.eColumns.CLS_DESC + "=:CLS_DESC"); sb.AppendLine(" AND " + ClassListDTO.eColumns.SEQ + "=:SEQ"); #endregion DataRequest req = new DataRequest(sb.ToString()); #region Parameters req.Parameters.Add("CLS_INFO_CD", DataType.VarChar, data.CLS_INFO_CD.Value); req.Parameters.Add("CLS_CD", DataType.VarChar, data.CLS_CD.Value); req.Parameters.Add("CLS_DESC", DataType.VarChar, data.CLS_DESC.Value); req.Parameters.Add("SEQ", DataType.Int32, data.SEQ.Value); #endregion return(db.ExecuteNonQuery(req)); }
/// <summary> /// Update record by using the table's primary key. /// </summary> /// <param name="database"></param> /// <param name="data">Data which to update.</param> /// <param name="oldCLS_INFO_CD">Old Key #1</param> /// <param name="oldCLS_CD">Old Key #2</param> /// <returns></returns> public int UpdateWithPK(Database database, ClassListDTO data, NZString oldCLS_INFO_CD, NZString oldCLS_CD) { Database db = UseDatabase(database); StringBuilder sb = new StringBuilder(); #region SQL Statement sb.AppendLine(" UPDATE " + data.TableName); sb.AppendLine(" SET "); sb.AppendLine(" " + ClassListDTO.eColumns.CLS_INFO_CD + "=:CLS_INFO_CD"); sb.AppendLine(" ," + ClassListDTO.eColumns.CLS_CD + "=:CLS_CD"); sb.AppendLine(" ," + ClassListDTO.eColumns.CLS_DESC + "=:CLS_DESC"); sb.AppendLine(" WHERE "); sb.AppendLine(" " + ClassListDTO.eColumns.CLS_INFO_CD + "=:oldCLS_INFO_CD"); sb.AppendLine(" AND " + ClassListDTO.eColumns.CLS_CD + "=:oldClassList"); #endregion DataRequest req = new DataRequest(sb.ToString()); #region Parameters req.Parameters.Add("CLS_INFO_CD", DataType.VarChar, data.CLS_INFO_CD.Value); req.Parameters.Add("CLS_CD", DataType.VarChar, data.CLS_CD.Value); req.Parameters.Add("CLS_DESC", DataType.VarChar, data.CLS_DESC.Value); req.Parameters.Add("oldCLS_INFO_CD", DataType.VarChar, oldCLS_INFO_CD.Value); req.Parameters.Add("oldCLS_CD", DataType.VarChar, oldCLS_CD.Value); #endregion return(db.ExecuteNonQuery(req)); }
public List <ClassListDTO> Show_SimilarClass_List(string did, string stcode) { SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "[Adobe].[SP_SimilarClass]"; cmd.Parameters.AddWithValue("@Did", did); cmd.Parameters.AddWithValue("@StCode", stcode); conn.Open(); DataTable dt = new DataTable(); SqlDataReader rdr; rdr = cmd.ExecuteReader(); dt.Load(rdr); List <ClassListDTO> list = new List <ClassListDTO>(); for (int i = 0; i < dt.Rows.Count; i++) { ClassListDTO classDTO = new ClassListDTO(); classDTO.ClassCode = dt.Rows[i]["did"].ToString(); classDTO.CourseName = dt.Rows[i]["namedars"].ToString(); classDTO.ProfName = dt.Rows[i]["Ost_Name"].ToString(); classDTO.ClassDateTime = dt.Rows[i]["Klas_Day"].ToString(); classDTO.ClassStartTime = dt.Rows[i]["ClassTime"].ToString();//classtime // classDTO.MergeCode = dt.Rows[i]["Merge_Code"].ToString(); list.Add(classDTO); //list.Insert(i, classDTO); } conn.Close(); return(list); }
public List <ClassListDTO> Show_Class_List(string stcode, string term) { SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "Adobe.SP_StudentClass"; cmd.Parameters.AddWithValue("@stcode", stcode); cmd.Parameters.AddWithValue("@term", term); conn.Open(); DataTable dt = new DataTable(); SqlDataReader rdr; rdr = cmd.ExecuteReader(); dt.Load(rdr); List <ClassListDTO> list = new List <ClassListDTO>(); for (int i = 0; i < dt.Rows.Count; i++) { ClassListDTO classDTO = new ClassListDTO(); classDTO.ClassCode = dt.Rows[i]["classID"].ToString(); classDTO.CourseName = dt.Rows[i]["courseName"].ToString(); classDTO.ProfName = dt.Rows[i]["Ost_Name"].ToString(); classDTO.ClassDateTime = dt.Rows[i]["Klas_Day"].ToString(); classDTO.ClassStartTime = dt.Rows[i]["ClassTime"].ToString();//classtime list.Add(classDTO); //list.Insert(i, classDTO); } conn.Close(); return(list); }
/// <summary> /// Insert new record into database. /// </summary> /// <param name="database"></param> /// <param name="data"></param> /// <returns></returns> public int AddNew(Database database, ClassListDTO data) { Database db = UseDatabase(database); StringBuilder sb = new StringBuilder(); #region SQL Statement sb.AppendLine(" INSERT INTO " + data.TableName + "("); sb.AppendLine(" " + ClassListDTO.eColumns.CLS_INFO_CD); sb.AppendLine(" ," + ClassListDTO.eColumns.CLS_CD); sb.AppendLine(" ," + ClassListDTO.eColumns.CLS_DESC); sb.AppendLine(") VALUES("); sb.AppendLine(" :CLS_INFO_CD"); sb.AppendLine(" ,:CLS_CD"); sb.AppendLine(" ,:CLS_DESC"); sb.AppendLine(" )"); #endregion DataRequest req = new DataRequest(sb.ToString()); #region Parameters req.Parameters.Add("CLS_INFO_CD", DataType.VarChar, data.CLS_INFO_CD.Value); req.Parameters.Add("CLS_CD", DataType.VarChar, data.CLS_CD.Value); req.Parameters.Add("CLS_DESC", DataType.VarChar, data.CLS_DESC.Value); #endregion return(db.ExecuteNonQuery(req)); }
public int AddNewAndCheck(Database database, ClassListDTO data) { Database db = UseDatabase(database); if (checkDup(database, data.CLS_INFO_CD, data.CLS_CD, data.SEQ)) { return(0); } return(AddNew(db, data)); }
/// <summary> /// Check exist before manipulate data. If found record will update data. Otherwise insert new data. /// </summary> /// <param name="database"></param> /// <param name="data"></param> /// <returns></returns> public int AddNewOrUpdate(Database database, ClassListDTO data) { Database db = UseDatabase(database); if (Exist(database, data.CLS_INFO_CD, data.CLS_CD)) { return(UpdateWithoutPK(db, data)); } return(AddNew(db, data)); }
private string GetInventoryUMCls(NZString InventoryUMCls) { ClassListBIZ biz = new ClassListBIZ(); ClassListDTO dto = biz.LoadByPK((NZString)"UM_CLS", InventoryUMCls); if (dto == null) { return(string.Empty); } return(dto.CLS_DESC.StrongValue); }
internal int DeleteClassList(ClassListUIDM classUIDM) { ClassListDTO data = new ClassListDTO(); data.CLS_INFO_CD = classUIDM.ClsInfoCd; data.CLS_CD = classUIDM.ClsCd; data.CLS_DESC = classUIDM.ClsDesc; data.SEQ = classUIDM.SEQ; int Del = DeleteClassList(data); return(Del); }
internal int AddClassList(ClassListUIDM classUIDM, int EditFlag) { ClassListDTO data = new ClassListDTO(); data.CLS_INFO_CD = classUIDM.ClsInfoCd; data.CLS_CD = classUIDM.ClsCd; data.CLS_DESC = classUIDM.ClsDesc; data.SEQ = classUIDM.SEQ; data.EDIT_FLAG.Value = EditFlag; int Add = AddClassList(data); return(Add); }
private void SetClassDtoChildren(ClassListDTO dto, IEnumerable <BlogClass> list) { var children = list.Where(c => c.ParentId == dto.Id); if (children.Any()) { var childrenDto = children.MapToCollection <ClassListDTO>(); dto.Children = childrenDto; foreach (var child in childrenDto) { SetClassDtoChildren(child, list); } } }
public async Task <List <ClassListDTO> > GetClassList(Guid blogId) { IEnumerable <BlogClass> classes = await _classDS.GetFilteredAsync(x => x.BlogId == blogId); ClassListDTO emptyDto = new ClassListDTO { Id = null }; SetClassDtoChildren(emptyDto, classes.ToList()); //classList. return(emptyDto.Children); }
public DataTable CheckMergeCode(ClassListDTO mrgClass) { SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "[dbo].[SP_getMergeCode]"; cmd.Parameters.AddWithValue("@term", mrgClass.Semester); cmd.Parameters.AddWithValue("@Merge_Code", mrgClass.MergeCode); conn.Open(); DataTable dt = new DataTable(); SqlDataReader rdr; rdr = cmd.ExecuteReader(); dt.Load(rdr); conn.Close(); return(dt); }
public void EditMergeClass(ClassListDTO cls) { SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "[dbo].[SP_Update_MergeClassByterm-Merge_Code]"; cmd.Parameters.AddWithValue("@term", cls.Semester); cmd.Parameters.AddWithValue("@date_first_session", cls.FirstSession); cmd.Parameters.AddWithValue("@count_sessions", cls.SessionCount); cmd.Parameters.AddWithValue("@merge_Code", cls.MergeCode); cmd.Parameters.AddWithValue("@idostad", cls.ProfID); cmd.Parameters.AddWithValue("@lessonCode", cls.CourseCode); cmd.Parameters.AddWithValue("@SaatStart", cls.ClassStartTime); cmd.Parameters.AddWithValue("@SaatEnd", cls.ClassEndTime); cmd.Parameters.AddWithValue("@IdRoz", cls.ClassDay); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); }
public List <ClassListDTO> Show_similar_Merge_Class_List(List <string> listOfDid) { List <ClassListDTO> list = new List <ClassListDTO>(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; foreach (var item in listOfDid) { string did = item; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "[dbo].[SP_StudentMergeSimilarClasses]"; cmd.Parameters.AddWithValue("@did", did); // cmd.Parameters.AddWithValue("@stCode", stcode); conn.Open(); DataTable dt = new DataTable(); SqlDataReader rdr; rdr = cmd.ExecuteReader(); dt.Load(rdr); for (int i = 0; i < dt.Rows.Count; i++) { ClassListDTO classDTO = new ClassListDTO(); classDTO.ClassCode = dt.Rows[i]["did"].ToString(); classDTO.CourseName = dt.Rows[i]["namedars"].ToString(); classDTO.ProfName = dt.Rows[i]["Ost_Name"].ToString(); classDTO.ClassDateTime = dt.Rows[i]["Klas_Day"].ToString(); classDTO.ClassStartTime = dt.Rows[i]["ClassTime"].ToString();//time classDTO.MergeCode = dt.Rows[i]["Merge_Code"].ToString(); list.Add(classDTO); //list.Insert(i, classDTO); } conn.Close(); } return(list); }
public void MergeClass(ClassListDTO cls) { clsDAO.MergeClass(cls); }
public void EditMergeClass(ClassListDTO cls) { clsDAO.EditMergeClass(cls); }
internal int DeleteClassList(ClassListDTO data) { ClassListBIZ biz = new ClassListBIZ(); return(biz.DeleteData(data)); }
public DataTable CheckMergeCode(ClassListDTO mrgClass) { return(clsDAO.CheckMergeCode(mrgClass)); }
internal int AddClassList(ClassListDTO data) { ClassListBIZ biz = new ClassListBIZ(); return(biz.AddData(data)); }
public int DeleteData(ClassListDTO data) { ClassListDAO dao = new ClassListDAO(CommonLib.Common.CurrentDatabase); return(dao.Delete(null, data)); }
public int AddData(ClassListDTO data) { ClassListDAO dao = new ClassListDAO(CommonLib.Common.CurrentDatabase); return(dao.AddNewAndCheck(null, data)); }
public int UpdateData(ClassListDTO data) { ClassListDAO dao = new ClassListDAO(CommonLib.Common.CurrentDatabase); return(dao.UpdateWithoutPK(null, data)); }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <returns>If save data operation completed will return true. Otherwise return false.</returns> public bool SaveData(WorkResultEntryUIDM model, DataDefine.eCONSUMPTION_CLS ConsumptionClass) { ItemBIZ bizItem = new ItemBIZ(); ClassListBIZ bizClassList = new ClassListBIZ(); InventoryBIZ biz = new InventoryBIZ(); IssueEntryValidator valLot = new IssueEntryValidator(); // Load default over consumption checking. ClassListDTO dtoOverConsumptionCheck = bizClassList.LoadByPK((NZString)DataDefine.OVER_CONSUME_CHK, (NZString)DataDefine.Convert2ClassCode(DataDefine.eOVER_CONSUME_CHK.DEFAULT)); bool bOverConsumeChk = false; if (dtoOverConsumptionCheck != null && dtoOverConsumptionCheck.CLS_DESC.NVL(String.Empty) == "1") { bOverConsumeChk = true; } //string mode = "UPD"; //if (model.WorkOrderNo.IsNull) //{ // mode = "ADD"; //} #region Validate data //== Validate Header, contain: ItemCode, Order Location and Qty. #region Validate mandatory WorkResultEntryValidator workResultEntryValidator = new WorkResultEntryValidator(); ItemValidator itemValidator = new ItemValidator(); DealingValidator locationValidator = new DealingValidator(); CommonBizValidator commonVal = new CommonBizValidator(); ValidateException.ThrowErrorItem(workResultEntryValidator.CheckWorkResultDate(model.WorkResultDate)); ValidateException.ThrowErrorItem(itemValidator.CheckEmptyItemCode(model.ItemCode)); ValidateException.ThrowErrorItem(workResultEntryValidator.CheckEmptyShiftType(model.ShipClass)); ValidateException.ThrowErrorItem(workResultEntryValidator.CheckDifferentLocationOfItem(model.DataView)); BusinessException itemFound = itemValidator.CheckItemNotExist(model.ItemCode); if (itemFound != null) { ValidateException.ThrowErrorItem(itemFound.Error); } if (ConsumptionClass != DataDefine.eCONSUMPTION_CLS.No) { ValidateException.ThrowErrorItem(locationValidator.CheckEmptyLocationCode(model.OrderLoc)); ValidateException.ThrowErrorItem(locationValidator.CheckNotExistsLocationCode(model.OrderLoc)); } ValidateException.ThrowErrorItem(locationValidator.CheckEmptyLocationCode(model.StoredLoc)); ValidateException.ThrowErrorItem(locationValidator.CheckNotExistsLocationCode(model.StoredLoc)); ValidateException.ThrowErrorItem(workResultEntryValidator.CheckWorkResultQty(model.WorkResultQty)); ValidateException.ThrowErrorItem(workResultEntryValidator.CheckWorkResultGoodQty((NZDecimal)(model.WorkResultQty.StrongValue - model.NGQty.StrongValue))); // Check LotNo ValidateException.ThrowErrorItem(commonVal.CheckInputLot(model.ItemCode, new NZString(), model.LotNo, false)); #endregion //== Validate Detail list. if (ConsumptionClass == DataDefine.eCONSUMPTION_CLS.Manual) { List <WorkResultEntryViewDTO> listItems = DTOUtility.ConvertDataTableToList <WorkResultEntryViewDTO>(model.DataView); #region Validate detail list. // Check ItemCD & LotNo List <string> listInvalidLotNo = new List <string>(); List <string> listInvalidConsumptionQty = new List <string>(); for (int i = 0; i < listItems.Count; i++) { BusinessException itemChildNotFound = itemValidator.CheckItemNotExist(listItems[i].ITEM_CD); if (itemChildNotFound != null) { ValidateException.ThrowErrorItem(itemChildNotFound.Error); } ItemDTO dtoItem = bizItem.LoadItem(listItems[i].ITEM_CD); WorkResultEntryViewDTO line = listItems[i]; //line.LOT_CONTROL_CLS = dtoItem.LOT_CONTROL_CLS; if (line.LOT_CONTROL_CLS.StrongValue == DataDefine.Convert2ClassCode(DataDefine.eLOT_CONTROL_CLS.Yes) && (line.LOT_NO.IsNull || line.LOT_NO.StrongValue.Trim() == string.Empty)) { if (listInvalidLotNo.Contains(line.ITEM_CD.StrongValue)) { continue; } listInvalidLotNo.Add(line.ITEM_CD.StrongValue); } if (bOverConsumeChk) { if (line.CONSUMPTION_QTY.StrongValue > line.ON_HAND_QTY.StrongValue) { if (listInvalidConsumptionQty.Contains(line.ITEM_CD.StrongValue)) { continue; } listInvalidConsumptionQty.Add(line.ITEM_CD.StrongValue); } } ValidateException.ThrowErrorItem(commonVal.CheckInputLot(line.ITEM_CD, line.LOC_CD, line.LOT_NO, true)); } // Generate item doesn't input LOT_NO if (listInvalidLotNo.Count > 0) { listInvalidLotNo.Sort(); string errorItems = string.Empty; for (int i = 0; i < listInvalidLotNo.Count; i++) { if (i != 0) { errorItems += ", "; } errorItems += listInvalidLotNo[i]; } ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0050.ToString(), new object[] { errorItems })); return(false); } // Generate list item that input consumption qty more than stock onhand qty. if (listInvalidConsumptionQty.Count > 0) { listInvalidConsumptionQty.Sort(); string errorItems = string.Empty; for (int i = 0; i < listInvalidConsumptionQty.Count; i++) { if (i != 0) { errorItems += ", "; } errorItems += listInvalidConsumptionQty[i]; } ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0051.ToString(), new object[] { errorItems })); return(false); } #endregion // Validate Child Item to support Parent Item. #region Validate Child Item to support Parent item. // Summary Consumption Qty by Item (not include LotNo) and then check compare with RequestQty. InventoryBIZ bizInventory = new InventoryBIZ(); List <WorkResultEntryViewDTO> listSourceChildItems = bizInventory.LoadConsumptionListFromItemCode(model.ItemCode, model.OrderLoc, model.WorkResultQty); for (int i = 0; i < listSourceChildItems.Count; i++) { object objSumByItem = model.DataView.Compute( String.Format("SUM({0})", WorkResultEntryViewDTO.eColumns.CONSUMPTION_QTY), String.Format("{0} = '{1}'", WorkResultEntryViewDTO.eColumns.ITEM_CD, listSourceChildItems[i].ITEM_CD.StrongValue) ); decimal sumConsumptionQty = 0; if (objSumByItem != null && objSumByItem != DBNull.Value) { sumConsumptionQty = Convert.ToDecimal(objSumByItem); } decimal diffQty = Math.Abs(sumConsumptionQty - listSourceChildItems[i].CONSUMPTION_QTY.StrongValue); if (sumConsumptionQty < listSourceChildItems[i].REQUEST_QTY.StrongValue) // Total of ConsumtpionQty < RequestQty { // Confirmation to continue save. MessageDialogResult dr = MessageDialog.ShowConfirmation(null, Message.LoadMessage(TKPMessages.eConfirm.CFM0001.ToString(), new object[] { listSourceChildItems[i].ITEM_CD.StrongValue, model.ItemCode.StrongValue, diffQty.ToString(DataDefine.DEFAULT_FORMAT_NUMBER) }), MessageDialogButtons.YesNo); if (dr == MessageDialogResult.No) { return(false); } } else if (sumConsumptionQty > listSourceChildItems[i].REQUEST_QTY.StrongValue) // Total of ConsumtpionQty > RequestQty { // Confirmation to continue save. MessageDialogResult dr = MessageDialog.ShowConfirmation(null, Message.LoadMessage(TKPMessages.eConfirm.CFM0002.ToString(), new object[] { listSourceChildItems[i].ITEM_CD.StrongValue, model.ItemCode.StrongValue, diffQty.ToString(DataDefine.DEFAULT_FORMAT_NUMBER) }), MessageDialogButtons.YesNo); if (dr == MessageDialogResult.No) { return(false); } } } #endregion } #endregion DataTable dtData; if (model.DataView == null) { WorkResultEntryViewDTO dto = new WorkResultEntryViewDTO(); dto.CreateDataTableSchema(out dtData); } else { dtData = model.DataView; } DataTable dtAdd = dtData.GetChanges(DataRowState.Added); DataTable dtUpdate = dtData.GetChanges(DataRowState.Modified); DataTable dtDelete = dtData.GetChanges(DataRowState.Deleted); List <InventoryTransactionDTO> listAdd = new List <InventoryTransactionDTO>(); List <InventoryTransactionDTO> listUpdate = new List <InventoryTransactionDTO>(); List <InventoryTransactionDTO> listDelete = new List <InventoryTransactionDTO>(); Database db = null; try { db = Common.CurrentDatabase; db.KeepConnection = true; db.BeginTransaction(); //TransactionValidator valTran = new TransactionValidator(); //InventoryTransBIZ bizTran = new InventoryTransBIZ(); //bizTran.l #region Header NZString runningNo = new NZString(); //ให้ generate lot ใหม่อีกครั้ง กรณีกรอกพร้อมกัน 2 เครื่อง ไม่งั้นมันจะ insert ข้อมูลมั่ว // ที่ใส่ตรงนี้เพราะว่า จะได้แก้ model.LotNo ก่อนที่จะสร้าง object dto //เนื่องจาก reserve ก็มีดึง lot no ไปใช้ if (model.WorkResultNo.IsNull) { RunningNumberBIZ runnningBiz = new RunningNumberBIZ(); NZString strCompleteLotNo = runnningBiz.GetCompleteLotNo(new NZDateTime(null, model.WorkResultDate.StrongValue), model.StoredLoc, model.ItemCode, new NZInt(null, 0)); model.LotNo = strCompleteLotNo; } InventoryTransactionDTO dtoWorkResult = CreateDTOForWorkResult(model); InventoryTransactionDTO dtoNGResult = CreateDTOForNGResult(model); InventoryTransactionDTO dtoReserveResult = CreateDTOForReserveResult(model); InventoryTransBIZ bizTran = new InventoryTransBIZ(); bizTran.LockRefSlipNumber(dtoWorkResult.REF_SLIP_NO); if (model.WorkResultNo.IsNull) { RunningNumberBIZ runningNumberBIZ = new RunningNumberBIZ(); runningNo = runningNumberBIZ.GetCompleteRunningNo((NZString)"WORK_RESULT_SLIP_NO", (NZString)"TB_INV_TRANS_TR"); // Create new transaction. dtoWorkResult.SLIP_NO = runningNo; dtoNGResult.SLIP_NO = runningNo; dtoReserveResult.SLIP_NO = runningNo; listAdd.Add(dtoWorkResult); if (model.NGQty.NVL(0) > 0) { listAdd.Add(dtoNGResult); } if (model.ReserveQty.NVL(0) > 0) { listAdd.Add(dtoReserveResult); } } else { // Update old transaction runningNo = model.WorkResultNo; listUpdate.Add(dtoWorkResult); if (!model.NGTransactionID.IsNull) // UPDATE NG IF IT ALREADY HAS NG QTY { listUpdate.Add(dtoNGResult); } else if (model.NGQty.NVL(0) > 0) // ADD NEW NG TRANS IF NEW NG IS INPUT { //dtoNGResult.SLIP_NO = dtoWorkResult.SLIP_NO; listAdd.Add(dtoNGResult); } if (!model.ReserveTransactionID.IsNull) // UPDATE Reserve IF IT ALREADY HAS Reserve QTY { listUpdate.Add(dtoReserveResult); } else if (model.ReserveQty.NVL(0) > 0) // ADD NEW Reserve TRANS IF NEW NG IS INPUT { //dtoReserveResult.SLIP_NO = dtoWorkResult.SLIP_NO; listAdd.Add(dtoNGResult); } } #endregion #region Detail #region Do Auto Consumption if (ConsumptionClass == DataDefine.eCONSUMPTION_CLS.Auto) { // WHEN CONSUMPTION IS AUTO // DELETE ALL OLD TRANSACTION FIRST THEN ADD NEW //Modify by Bunyapat L. //28 Apr 2011 //ให้สั่ง ClearConsumption ไปเลย List <WorkResultEntryViewDTO> listTMPDelete = null; List <InventoryTransactionDTO> listTmpDelete = null; if (dtData != null && dtData.Rows.Count > 0) { listTMPDelete = DTOUtility.ConvertDataTableToList <WorkResultEntryViewDTO>(dtData); listTmpDelete = new List <InventoryTransactionDTO>(); for (int i = 0; i < listTMPDelete.Count; i++) { WorkResultEntryViewDTO line = listTMPDelete[i]; InventoryTransactionDTO dto = CreateDTOForConsumption(model, line); dto.REF_NO = runningNo; listTmpDelete.Add(dto); } // Move to delete below section //biz.WorkResultItems(Common.CurrentDatabase, null, null, listTmpDelete); } biz.ClearConsumption(Common.CurrentDatabase, dtoWorkResult); if (dtData != null && dtData.Rows.Count > 0) { List <WorkResultEntryViewDTO> listTMPAdd = DTOUtility.ConvertDataTableToList <WorkResultEntryViewDTO>(dtData); // GET LOCATION INFORMATION DealingBIZ bizLoc = new DealingBIZ(); for (int i = 0; i < listTMPAdd.Count; i++) { DealingDTO dtoLoc = bizLoc.LoadLocation(listTMPAdd[i].LOC_CD); bool AllowNegative = dtoLoc.ALLOW_NEGATIVE.StrongValue == "01"; // GET CONSUMPTION ITEM FROM FIFO PROCESS WRITE BY KIMMIK. List <ActualOnhandViewDTO> dtoListActOnhand = biz.FifoListingProcess(Common.CurrentDatabase , listTMPAdd[i].ITEM_CD.StrongValue, listTMPAdd[i].LOC_CD.StrongValue , listTMPAdd[i].CONSUMPTION_QTY.StrongValue , !AllowNegative, AllowNegative); if (dtoListActOnhand != null && dtoListActOnhand.Count > 0) { for (int j = 0; j < dtoListActOnhand.Count; j++) { InventoryTransactionDTO dto = CreateDTOForConsumption(model, dtoListActOnhand[j]); dto.REF_NO = runningNo; listAdd.Add(dto); } } } } biz.WorkResultItems(Common.CurrentDatabase, listAdd, listUpdate, listDelete); } #endregion #region Do Manual Consumption if (ConsumptionClass == DataDefine.eCONSUMPTION_CLS.Manual) { List <InventoryTransactionDTO> listTmpDelete = new List <InventoryTransactionDTO>(); //== Update process. //Modify by Bunyapat L. //28 Apr 2011 //Manual consumption ให้ใช้การ insert เข้า Delete ทุกตัวที่เป็นตัวเก่า //แล้วค่อย Add ตัวใหม่แทน เพราะข้างใน function มันจะทำการ clear consumption ทั้งหมด ไม่งั้นจะเกิด bug ตอน update if (dtUpdate != null && dtUpdate.Rows.Count > 0) { List <WorkResultEntryViewDTO> listViewUpdate = DTOUtility.ConvertDataTableToList <WorkResultEntryViewDTO>(dtUpdate); for (int i = 0; i < listViewUpdate.Count; i++) { WorkResultEntryViewDTO line = listViewUpdate[i]; // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว InventoryTransactionDTO dto = CreateDTOForConsumption(model, line); dto.REF_NO = runningNo; //listUpdate.Add(dto); listAdd.Add(dto); listTmpDelete.Add((InventoryTransactionDTO)dto.Clone()); } } //== Insert process. if (dtAdd != null && dtAdd.Rows.Count > 0) { List <WorkResultEntryViewDTO> listViewAdd = DTOUtility.ConvertDataTableToList <WorkResultEntryViewDTO>(dtAdd); for (int i = 0; i < listViewAdd.Count; i++) { WorkResultEntryViewDTO line = listViewAdd[i]; InventoryTransactionDTO dto = CreateDTOForConsumption(model, line); dto.REF_NO = runningNo; listAdd.Add(dto); } } //== Delete process. if (dtDelete != null && dtDelete.Rows.Count > 0) { List <WorkResultEntryViewDTO> listViewDelete = DTOUtility.ConvertDataTableToList <WorkResultEntryViewDTO>(dtDelete); for (int i = 0; i < dtDelete.Rows.Count; i++) { WorkResultEntryViewDTO line = listViewDelete[i]; // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว InventoryTransactionDTO dto = CreateDTOForConsumption(model, line); dto.REF_NO = runningNo; listDelete.Add(dto); } } biz.WorkResultItems(Common.CurrentDatabase, null, null, listTmpDelete); biz.WorkResultItems(Common.CurrentDatabase, listAdd, listUpdate, listDelete); } #endregion #region Do No Consumption if (ConsumptionClass == DataDefine.eCONSUMPTION_CLS.No) { biz.WorkResultItems(Common.CurrentDatabase, listAdd, listUpdate, listDelete); } #endregion #endregion db.Commit(); } catch (Exception) { db.Rollback(); throw; } finally { if (db.DBConnectionState == ConnectionState.Open) { db.Close(); } } return(true); }
protected void drpDay_SelectedIndexChanged(object sender, EventArgs e) { mrgClass = (ClassListDTO)Session["mrgClass"]; mrgClass.ClassDay = Convert.ToInt32(drpDay.SelectedValue); Session["mrgClass"] = mrgClass; }
private void merge(int IsExist) { clss = (List <ClassListDTO>)Session["clss"]; mrgClass = (ClassListDTO)Session["mrgClass"]; //int classCode = (int)ViewState["classCode"]; //mrgClass.ProfID = (int)Session["idOstad"]; //nimsal = ViewState["nimsal"].ToString(); //string mergeCode = ViewState["mergeCode"].ToString(); //string count_sessions = ViewState["count_sessions"].ToString(); //string date_first_session = ViewState["date_first_session"].ToString(); //mrgClass.ClassDay = (int)ViewState["DayID"]; //string stime = ViewState["stime"].ToString(); //string etime = ViewState["etime"].ToString(); foreach (var item in clss) { item.MergeCode = mrgClass.MergeCode; item.CourseCode = mrgClass.CourseCode; item.CourseName = mrgClass.CourseName; item.FirstSession = mrgClass.FirstSession; item.SessionCount = mrgClass.SessionCount; item.ProfID = mrgClass.ProfID; item.Semester = mrgClass.Semester; item.ClassDay = mrgClass.ClassDay; item.ClassStartTime = mrgClass.ClassStartTime; item.ClassEndTime = mrgClass.ClassEndTime; item.ClassCount = clss.Count(); } if (clss.Count > 1 || IsExist == 1) { string temp = clss[clss.Count - 1].CourseName; for (int i = 0; i < clss.Count; i++) { if (i != clss.Count - 1) { temp += " " + clss[i].ClassCode + " و "; } else { temp += " " + clss[i].ClassCode; } } foreach (ClassListDTO item in clss) { item.ClassName = temp; clsB.MergeClass(item); } mergeClassDT = clsB.getMergeClass(nimsal); ViewState.Add("mergeClassDT", mergeClassDT); string msg = "کلاس ها با موفقیت ادغام شدند"; RadWindowManager1.RadAlert(msg, 0, 100, " پیام سیستم", ""); List <ClassListDTO> empty = new List <ClassListDTO>(); grdList.DataSource = empty; grdList.DataBind(); //cmbOstad.SelectedIndex = 0; txtmergeCode.Text = string.Empty; txtFirstSession.Text = string.Empty; txtSessionCount.Text = string.Empty; nimsal = ViewState["nimsal"].ToString(); bindInfoGrid(); } else if (clss.Count == 1) { string msg = "برای ادغام کردن کلاس، حداقل باید دو کلاس انتخاب کنید"; RadWindowManager1.RadAlert(msg, 0, 100, " پیام سیستم", ""); } else { string msg = "کلاسی را برای ادغام انتخاب نکرده اید"; RadWindowManager1.RadAlert(msg, 0, 100, " پیام سیستم", ""); } }
protected void btnMerge_Click(object sender, EventArgs e) { //if (cmbOstad.SelectedIndex > 0) //{ if (grdInfo.Items.Count != 0) { DataTable chkMrg; chkMrg = clsB.CheckMergeCode(txtmergeCode.Text); string chkCode = chkMrg.Rows[0]["CHK"].ToString(); if (chkCode == "2") { if (Convert.ToInt32(txtSessionCount.Text) >= 1 && Convert.ToInt32(txtSessionCount.Text) <= 20) { rvSessionCount.IsValid = true; RequiredFieldValidator1.IsValid = true; mrgClass = (ClassListDTO)Session["mrgClass"]; mrgClass.MergeCode = txtmergeCode.Text; mrgClass.CourseCode = txtCodeDars.Text; mrgClass.SessionCount = Convert.ToInt32(txtSessionCount.Text); mrgClass.FirstSession = txtFirstSession.Text; mrgClass.ProfID = (int)ViewState["profCode"]; mrgClass.ClassStartTime = RadTimePicker1.DateInput.Text.Substring(11, 5).Replace('-', ':'); mrgClass.ClassEndTime = RadTimePicker2.DateInput.Text.Substring(11, 5).Replace('-', ':'); Session["mrgClass"] = mrgClass; DataTable dtMergeCheck = new DataTable(); dtMergeCheck = clsB.CheckMergeCode(mrgClass); if (dtMergeCheck.Rows.Count == 0) { merge(0); clearList(); } else { radConfirm.VisibleOnPageLoad = true; } } else { rvSessionCount.IsValid = false; } } else { string msg = "کدی که برای ادغام انتخاب کرده اید تکراریست "; RadWindowManager1.RadAlert(msg, 0, 100, " پیام سیستم", ""); } } else { string msg = "کلاسی را برای ادغام انتخاب نکرده اید"; RadWindowManager1.RadAlert(msg, 0, 100, " پیام سیستم", ""); } //} //else //{ // RequiredFieldValidator1.IsValid = false; //} }