public object[] queryLstDataMstCustomerService(MST_CUSTOMER_SERVICE param) { log.Info("Start log INFO... queryLstDataMstCustomerService"); MsgForm msgError = new MsgForm(); List <MST_CUSTOMER_SERVICE> resultList = new List <MST_CUSTOMER_SERVICE>(); try { using (var db = new PaknampoScaleDBEntities()) { resultList = (from row in db.MST_CUSTOMER_SERVICE where row.CUSTOMER_ID == param.CUSTOMER_ID select row).ToList(); db.Dispose(); msgError.statusFlag = MsgForm.STATUS_SUCCESS; } } catch (Exception ex) { log.Error(ex.ToString(), ex); msgError.statusFlag = MsgForm.STATUS_ERROR; msgError.messageDescription = ex.ToString(); } finally { log.Info("End log INFO... queryLstDataMstCustomerService"); } return(new object[] { msgError, resultList }); }
public object[] insertOrUpdateDataMst009(MST_CUSTOMER param, List <MST_CUSTOMER_SERVICE> lstParamCustomerService, string flagAddEdit) { log.Info("Start log INFO... insertOrUpdateDataMst009"); MsgForm msgError = new MsgForm(); MST_CUSTOMER formInsert = new MST_CUSTOMER(); MST_CUSTOMER formUpdate = new MST_CUSTOMER(); MST_CUSTOMER_SERVICE formInsertCustomerService = new MST_CUSTOMER_SERVICE(); MST_CUSTOMER_SERVICE formUpdateCustomerService = new MST_CUSTOMER_SERVICE(); try { using (var db = new PaknampoScaleDBEntities()) { formUpdate = (from row in db.MST_CUSTOMER where row.CUSTOMER_ID == param.CUSTOMER_ID select row).FirstOrDefault(); if (flagAddEdit.Equals("A")) { if (Util.isEmpty(formUpdate)) { formInsert.CUSTOMER_ID = param.CUSTOMER_ID; formInsert.CUSTOMER_STATEMENT_STATUS = param.CUSTOMER_STATEMENT_STATUS; formInsert.CUSTOMER_NAME = param.CUSTOMER_NAME; formInsert.CUSTOMER_ADDRESS = param.CUSTOMER_ADDRESS; formInsert.CUSTOMER_DISTRICT = param.CUSTOMER_DISTRICT; formInsert.CUSTOMER_AMPHURE = param.CUSTOMER_AMPHURE; formInsert.CUSTOMER_PROVINCE = param.CUSTOMER_PROVINCE; formInsert.CUSTOMER_POSTCODE = param.CUSTOMER_POSTCODE; formInsert.CUSTOMER_TEL_NO = param.CUSTOMER_TEL_NO; formInsert.CUSTOMER_FAX = param.CUSTOMER_FAX; db.MST_CUSTOMER.Add(formInsert); log.Info("Update Data form MST_CUSTOMER" + " CUSTOMER_ID : " + formInsert.CUSTOMER_ID + " CUSTOMER_STATEMENT_STATUS : " + formInsert.CUSTOMER_STATEMENT_STATUS + " CUSTOMER_NAME : " + formInsert.CUSTOMER_NAME + " CUSTOMER_ADDRESS : " + formInsert.CUSTOMER_ADDRESS + " CUSTOMER_DISTRICT : " + formInsert.CUSTOMER_DISTRICT + " CUSTOMER_AMPHURE : " + formInsert.CUSTOMER_AMPHURE + " CUSTOMER_PROVINCE : " + formInsert.CUSTOMER_PROVINCE + " CUSTOMER_POSTCODE : " + formInsert.CUSTOMER_POSTCODE + " CUSTOMER_TEL_NO : " + formInsert.CUSTOMER_TEL_NO + " CUSTOMER_FAX : " + formInsert.CUSTOMER_FAX ); } } else if (flagAddEdit.Equals("E")) { if (Util.isNotEmpty(formUpdate)) { formUpdate.CUSTOMER_STATEMENT_STATUS = param.CUSTOMER_STATEMENT_STATUS; formUpdate.CUSTOMER_NAME = param.CUSTOMER_NAME; formUpdate.CUSTOMER_ADDRESS = param.CUSTOMER_ADDRESS; formUpdate.CUSTOMER_DISTRICT = param.CUSTOMER_DISTRICT; formUpdate.CUSTOMER_AMPHURE = param.CUSTOMER_AMPHURE; formUpdate.CUSTOMER_PROVINCE = param.CUSTOMER_PROVINCE; formUpdate.CUSTOMER_POSTCODE = param.CUSTOMER_POSTCODE; formUpdate.CUSTOMER_TEL_NO = param.CUSTOMER_TEL_NO; formUpdate.CUSTOMER_FAX = param.CUSTOMER_FAX; log.Info("Update Data form MST_CUSTOMER" + " CUSTOMER_STATEMENT_STATUS : " + formUpdate.CUSTOMER_STATEMENT_STATUS + " CUSTOMER_NAME : " + formUpdate.CUSTOMER_NAME + " CUSTOMER_ADDRESS : " + formUpdate.CUSTOMER_ADDRESS + " CUSTOMER_DISTRICT : " + formUpdate.CUSTOMER_DISTRICT + " CUSTOMER_AMPHURE : " + formUpdate.CUSTOMER_AMPHURE + " CUSTOMER_PROVINCE : " + formUpdate.CUSTOMER_PROVINCE + " CUSTOMER_POSTCODE : " + formUpdate.CUSTOMER_POSTCODE + " CUSTOMER_TEL_NO : " + formUpdate.CUSTOMER_TEL_NO + " CUSTOMER_FAX : " + formUpdate.CUSTOMER_FAX ); } } foreach (MST_CUSTOMER_SERVICE dbean in lstParamCustomerService) { formUpdateCustomerService = (from row in db.MST_CUSTOMER_SERVICE where row.CUSTOMER_SERVICE_ID == dbean.CUSTOMER_SERVICE_ID select row).FirstOrDefault(); if (Util.isEmpty(formUpdateCustomerService)) { //formInsertCustomerService.CUSTOMER_SERVICE_ID = dbean.CUSTOMER_SERVICE_ID; formInsertCustomerService = new MST_CUSTOMER_SERVICE(); formInsertCustomerService.CUSTOMER_SERVICE_ID = db.MST_CUSTOMER_SERVICE.Count() + 1; formInsertCustomerService.CUSTOMER_SERVICE_VALUE = dbean.CUSTOMER_SERVICE_VALUE; formInsertCustomerService.CUSTOMER_ID = dbean.CUSTOMER_ID; formInsertCustomerService.SERVICE_CHARGE_ID = dbean.SERVICE_CHARGE_ID; db.MST_CUSTOMER_SERVICE.Add(formInsertCustomerService); log.Info("Insert Data form MST_CUSTOMER_SERVICE" + " CUSTOMER_SERVICE_ID : " + formInsertCustomerService.CUSTOMER_SERVICE_ID + " CUSTOMER_SERVICE_VALUE : " + formInsertCustomerService.CUSTOMER_SERVICE_VALUE + " CUSTOMER_ID : " + formInsertCustomerService.CUSTOMER_ID + " SERVICE_CHARGE_ID : " + formInsertCustomerService.SERVICE_CHARGE_ID ); } else { formUpdateCustomerService.CUSTOMER_SERVICE_VALUE = dbean.CUSTOMER_SERVICE_VALUE; formUpdateCustomerService.CUSTOMER_ID = dbean.CUSTOMER_ID; formUpdateCustomerService.SERVICE_CHARGE_ID = dbean.SERVICE_CHARGE_ID; log.Info("Update Data form MST_CUSTOMER_SERVICE" + " CUSTOMER_SERVICE_ID : " + formUpdateCustomerService.CUSTOMER_SERVICE_ID + " CUSTOMER_SERVICE_VALUE : " + formUpdateCustomerService.CUSTOMER_SERVICE_VALUE + " CUSTOMER_ID : " + formUpdateCustomerService.CUSTOMER_ID + " SERVICE_CHARGE_ID : " + formUpdateCustomerService.SERVICE_CHARGE_ID ); } //if (flagAddEdit.Equals("A")) //{ // if (Util.isEmpty(formUpdateCustomerService)) // { // //formInsertCustomerService.CUSTOMER_SERVICE_ID = dbean.CUSTOMER_SERVICE_ID; // formInsertCustomerService = new MST_CUSTOMER_SERVICE(); // formInsertCustomerService.CUSTOMER_SERVICE_ID = db.MST_CUSTOMER_SERVICE.Count() + 1; // formInsertCustomerService.CUSTOMER_SERVICE_VALUE = dbean.CUSTOMER_SERVICE_VALUE; // formInsertCustomerService.CUSTOMER_ID = dbean.CUSTOMER_ID; // formInsertCustomerService.SERVICE_CHARGE_ID = dbean.SERVICE_CHARGE_ID; // db.MST_CUSTOMER_SERVICE.Add(formInsertCustomerService); // log.Info("Insert Data form MST_CUSTOMER_SERVICE" // + " CUSTOMER_SERVICE_ID : " + formInsertCustomerService.CUSTOMER_SERVICE_ID // + " CUSTOMER_SERVICE_VALUE : " + formInsertCustomerService.CUSTOMER_SERVICE_VALUE // + " CUSTOMER_ID : " + formInsertCustomerService.CUSTOMER_ID // + " SERVICE_CHARGE_ID : " + formInsertCustomerService.SERVICE_CHARGE_ID // ); // } //} //else if (flagAddEdit.Equals("E")) //{ // if (Util.isNotEmpty(formUpdateCustomerService)) // { // formUpdateCustomerService.CUSTOMER_SERVICE_VALUE = dbean.CUSTOMER_SERVICE_VALUE; // formUpdateCustomerService.CUSTOMER_ID = dbean.CUSTOMER_ID; // formUpdateCustomerService.SERVICE_CHARGE_ID = dbean.SERVICE_CHARGE_ID; // log.Info("Update Data form MST_CUSTOMER_SERVICE" // + " CUSTOMER_SERVICE_ID : " + formUpdateCustomerService.CUSTOMER_SERVICE_ID // + " CUSTOMER_SERVICE_VALUE : " + formUpdateCustomerService.CUSTOMER_SERVICE_VALUE // + " CUSTOMER_ID : " + formUpdateCustomerService.CUSTOMER_ID // + " SERVICE_CHARGE_ID : " + formUpdateCustomerService.SERVICE_CHARGE_ID // ); // } //} db.SaveChanges(); } msgError.statusFlag = MsgForm.STATUS_SUCCESS; } } catch (Exception ex) { log.Error(ex.ToString(), ex); msgError.statusFlag = MsgForm.STATUS_ERROR; msgError.messageDescription = ex.ToString(); } finally { log.Info("End log INFO... insertOrUpdateDataMst009"); } return(new object[] { msgError, formUpdate }); }