private bool SaveMPart(M_PART mPart) { using (CHubEntities db = new CHubEntities()) { M_PART_BLL mPartBLL = new M_PART_BLL(); if (mPartBLL.Exist(mPart.PART_NO)) { //must exist in m_part otherwise error if (mPart != null && !string.IsNullOrEmpty(mPart.TC_CATEGORY_BY_MAN)) { M_PART currMpart = mPartBLL.GetMPartByPartNo(mPart.PART_NO); currMpart.TC_CATEGORY_BY_MAN = mPart.TC_CATEGORY_BY_MAN; mPartBLL.Update(currMpart); } return(true); } else { //error part LogHelper.WriteErrorLog(string.Format("Fail Save Action, reason: Wrong partNo {0}", mPart.PART_NO)); return(false); } } }
public bool SaveTCPartData(TC_PART_HS partHS, M_PART mPart) { using (CHubEntities db = new CHubEntities()) { M_PART_BLL mPartBLL = new M_PART_BLL(); if (mPartBLL.Exist(partHS.PART_NO)) { //must exist in m_part otherwise error if (mPart != null && !string.IsNullOrEmpty(mPart.TC_CATEGORY_BY_MAN)) { M_PART currMpart = mPartBLL.GetMPartByPartNo(partHS.PART_NO); currMpart.TC_CATEGORY_BY_MAN = mPart.TC_CATEGORY_BY_MAN; mPartBLL.Update(currMpart); } if (partHS != null) { TC_PART_HS_BLL pHSBLL = new TC_PART_HS_BLL(db); if (pHSBLL.Exist(partHS.PART_NO)) { //update TC_PART_HS existModel = pHSBLL.GetTCPartHS(partHS.PART_NO); List <string> skipList = new List <string>(); skipList.Add("PART_NO"); skipList.Add("CREATED_BY"); skipList.Add("CREATE_DATE"); skipList.Add("UPDATED_BY"); skipList.Add("RECORD_DATE"); ClassConvert.DrawObj(partHS, existModel, skipList); existModel.UPDATED_BY = Session[CHubConstValues.SessionUser].ToString(); existModel.RECORD_DATE = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")); pHSBLL.update(existModel, false); } else { //add partHS.CREATED_BY = Session[CHubConstValues.SessionUser].ToString(); partHS.CREATE_DATE = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")); partHS.UPDATED_BY = Session[CHubConstValues.SessionUser].ToString(); partHS.RECORD_DATE = partHS.CREATE_DATE; pHSBLL.Add(partHS, false); } } db.SaveChanges(); return(true); } else { //error part LogHelper.WriteErrorLog(string.Format("Fail Save Action, reason: Wrong partNo {0}", partHS.PART_NO)); return(false); } } }