private HREmployeePhotoEntity BuildHREmployeePhotoEntity() { HREmployeePhotoEntity hREmployeePhotoEntity = CurrentHREmployeePhotoEntity; if (ddlEmployeeID.Items.Count > 0) { if (ddlEmployeeID.SelectedValue == "0") { } else { hREmployeePhotoEntity.EmployeeID = Int64.Parse(ddlEmployeeID.SelectedValue); } } hREmployeePhotoEntity.CurrentFileName = txtCurrentFileName.Text.Trim(); hREmployeePhotoEntity.Extension = txtExtension.Text.Trim(); hREmployeePhotoEntity.Remarks = txtRemarks.Text.Trim(); hREmployeePhotoEntity.Path = txtPath.Text.Trim(); hREmployeePhotoEntity.OriginalFileName = txtOriginalFileName.Text.Trim(); hREmployeePhotoEntity.FileType = txtFileType.Text.Trim(); hREmployeePhotoEntity.IsCurrent = chkIsCurrent.Checked; return(hREmployeePhotoEntity); }
Int64 IHREmployeePhotoDataAccess.Add(HREmployeePhotoEntity hREmployeePhotoEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(hREmployeePhotoEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(hREmployeePhotoEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private Int64 UpdateTran(HREmployeePhotoEntity hREmployeePhotoEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeePhoto_SET"; Database db = DatabaseFactory.CreateDatabase(); using (DbCommand cmd = db.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option, db); AddOutputParameter(cmd, db); AddFilterExpressionParameter(cmd, filterExpression, db); db.AddInParameter(cmd, "@EmployeePhotoID", DbType.Int64, hREmployeePhotoEntity.EmployeePhotoID); db.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hREmployeePhotoEntity.EmployeeID); db.AddInParameter(cmd, "@CurrentFileName", DbType.String, hREmployeePhotoEntity.CurrentFileName); db.AddInParameter(cmd, "@Extension", DbType.String, hREmployeePhotoEntity.Extension); db.AddInParameter(cmd, "@Remarks", DbType.String, hREmployeePhotoEntity.Remarks); db.AddInParameter(cmd, "@Path", DbType.String, hREmployeePhotoEntity.Path); db.AddInParameter(cmd, "@OriginalFileName", DbType.String, hREmployeePhotoEntity.OriginalFileName); db.AddInParameter(cmd, "@FileType", DbType.String, hREmployeePhotoEntity.FileType); db.AddInParameter(cmd, "@IsCurrent", DbType.Boolean, hREmployeePhotoEntity.IsCurrent); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { using (IDataReader reader = db.ExecuteReader(cmd, transaction)) { returnCode = GetReturnCodeFromParameter(cmd); } if (returnCode > 0) { transaction.Commit(); } else { throw new ArgumentException("Error Code." + returnCode.ToString()); } } catch (Exception ex) { transaction.Rollback(); throw ex; } finally { transaction.Dispose(); connection.Close(); connection = null; } } return(returnCode); }
private void SaveHREmployeePhotoEntity() { if (IsValid) { try { HREmployeePhotoEntity hREmployeePhotoEntity = BuildHREmployeePhotoEntity(); Int64 result = -1; if (hREmployeePhotoEntity.IsNew) { result = FCCHREmployeePhoto.GetFacadeCreate().Add(hREmployeePhotoEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(HREmployeePhotoEntity.FLD_NAME_EmployeePhotoID, hREmployeePhotoEntity.EmployeePhotoID.ToString(), SQLMatchType.Equal); result = FCCHREmployeePhoto.GetFacadeCreate().Update(hREmployeePhotoEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _EmployeePhotoID = 0; _HREmployeePhotoEntity = new HREmployeePhotoEntity(); PrepareInitialView(); BindHREmployeePhotoList(); if (hREmployeePhotoEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Employee Photo Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "Employee Photo Information has been updated successfully.", false); } } else { if (hREmployeePhotoEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Employee Photo Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Employee Photo Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
protected void lvHREmployeePhoto_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 EmployeePhotoID; Int64.TryParse(e.CommandArgument.ToString(), out EmployeePhotoID); if (EmployeePhotoID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _EmployeePhotoID = EmployeePhotoID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(HREmployeePhotoEntity.FLD_NAME_EmployeePhotoID, EmployeePhotoID.ToString(), SQLMatchType.Equal); HREmployeePhotoEntity hREmployeePhotoEntity = new HREmployeePhotoEntity(); result = FCCHREmployeePhoto.GetFacadeCreate().Delete(hREmployeePhotoEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _EmployeePhotoID = 0; _HREmployeePhotoEntity = new HREmployeePhotoEntity(); PrepareInitialView(); BindHREmployeePhotoList(); MiscUtil.ShowMessage(lblMessage, "Employee Photo has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete Employee Photo.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private Int64 DeleteTran(HREmployeePhotoEntity hREmployeePhotoEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeePhoto_SET"; Database db = DatabaseFactory.CreateDatabase(); using (DbCommand cmd = db.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd, db); AddFilterExpressionParameter(cmd, filterExpression, db); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { using (IDataReader reader = db.ExecuteReader(cmd, transaction)) { returnCode = GetReturnCodeFromParameter(cmd); } if (returnCode >= 0) { transaction.Commit(); } else { throw new ArgumentException("Error Code." + returnCode.ToString()); } } catch (Exception ex) { transaction.Rollback(); throw ex; } finally { transaction.Dispose(); connection.Close(); connection = null; } } return(returnCode); }
protected void afuFiles_UploadedComplete(object sender, AsyncFileUploadEventArgs e) { String fe = SqlExpressionBuilder.PrepareFilterExpression(HREmployeePhotoEntity.FLD_NAME_EmployeeID, OverviewEmployeeID.ToString(), SQLMatchType.Equal); IList <HREmployeePhotoEntity> lstmemberImageEntity = FCCHREmployeePhoto.GetFacadeCreate().GetIL(null, null, String.Empty, fe, DatabaseOperationType.LoadWithFilterExpression); HREmployeePhotoEntity memberImageEntity = new HREmployeePhotoEntity(); Boolean isSaveFlag = true; if (lstmemberImageEntity != null && lstmemberImageEntity.Count > 0) { isSaveFlag = false; } memberImageEntity.EmployeeID = this.OverviewEmployeeID; memberImageEntity.OriginalFileName = Path.GetFileName(e.FileName); memberImageEntity.CurrentFileName = Guid.NewGuid().ToString() + Path.GetExtension(e.FileName); memberImageEntity.FileType = ""; memberImageEntity.Extension = Path.GetExtension(e.FileName); memberImageEntity.Path = FileUploadConstants.HR.Employee + memberImageEntity.CurrentFileName; memberImageEntity.Remarks = String.Empty; memberImageEntity.IsCurrent = true; Int64 result = -1; if (isSaveFlag) { result = FCCHREmployeePhoto.GetFacadeCreate().Add(memberImageEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { result = FCCHREmployeePhoto.GetFacadeCreate().Update(memberImageEntity, fe, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { MiscUtil.ShowMessage(lblMessage, "Image Uploaded Successfully.", false); BindMemberImageList(); } // file upload afuFiles.SaveAs(Server.MapPath(memberImageEntity.Path)); //LoadFileListGried BindMemberImageList(); }
private Int64 Update(HREmployeePhotoEntity hREmployeePhotoEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeePhoto_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@EmployeePhotoID", DbType.Int64, hREmployeePhotoEntity.EmployeePhotoID); Database.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hREmployeePhotoEntity.EmployeeID); Database.AddInParameter(cmd, "@CurrentFileName", DbType.String, hREmployeePhotoEntity.CurrentFileName); Database.AddInParameter(cmd, "@Extension", DbType.String, hREmployeePhotoEntity.Extension); Database.AddInParameter(cmd, "@Remarks", DbType.String, hREmployeePhotoEntity.Remarks); Database.AddInParameter(cmd, "@Path", DbType.String, hREmployeePhotoEntity.Path); Database.AddInParameter(cmd, "@OriginalFileName", DbType.String, hREmployeePhotoEntity.OriginalFileName); Database.AddInParameter(cmd, "@FileType", DbType.String, hREmployeePhotoEntity.FileType); Database.AddInParameter(cmd, "@IsCurrent", DbType.Boolean, hREmployeePhotoEntity.IsCurrent); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("HREmployeePhotoEntity already exists. Please specify another HREmployeePhotoEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("HREmployeePhotoEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("HREmployeePhotoEntity already exists. Please specify another HREmployeePhotoEntity."); } } } } return(returnCode); }
private Int64 Delete(HREmployeePhotoEntity hREmployeePhotoEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeePhoto_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("HREmployeePhotoEntity already exists. Please specify another HREmployeePhotoEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("HREmployeePhotoEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("HREmployeePhotoEntity already exists. Please specify another HREmployeePhotoEntity."); } } } } return(returnCode); }
private void PrepareEditView() { HREmployeePhotoEntity hREmployeePhotoEntity = CurrentHREmployeePhotoEntity; if (!hREmployeePhotoEntity.IsNew) { if (ddlEmployeeID.Items.Count > 0 && hREmployeePhotoEntity.EmployeeID != null) { ddlEmployeeID.SelectedValue = hREmployeePhotoEntity.EmployeeID.ToString(); } txtCurrentFileName.Text = hREmployeePhotoEntity.CurrentFileName.ToString(); txtExtension.Text = hREmployeePhotoEntity.Extension.ToString(); txtRemarks.Text = hREmployeePhotoEntity.Remarks.ToString(); txtPath.Text = hREmployeePhotoEntity.Path.ToString(); txtOriginalFileName.Text = hREmployeePhotoEntity.OriginalFileName.ToString(); txtFileType.Text = hREmployeePhotoEntity.FileType.ToString(); chkIsCurrent.Checked = hREmployeePhotoEntity.IsCurrent; btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
protected void btnAddNew_Click(object sender, EventArgs e) { _EmployeePhotoID = 0; _HREmployeePhotoEntity = new HREmployeePhotoEntity(); PrepareInitialView(); }
Int64 IHREmployeePhotoFacade.Delete(HREmployeePhotoEntity hREmployeePhotoEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateHREmployeePhotoDataAccess().Delete(hREmployeePhotoEntity, filterExpression, option, reqTran)); }
Int64 IHREmployeePhotoFacade.Add(HREmployeePhotoEntity hREmployeePhotoEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateHREmployeePhotoDataAccess().Add(hREmployeePhotoEntity, option, reqTran)); }