Int64 IREQRequisitionUploadInfoDataAccess.Add(REQRequisitionUploadInfoEntity rEQRequisitionUploadInfoEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(rEQRequisitionUploadInfoEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(rEQRequisitionUploadInfoEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private Int64 UpdateTran(REQRequisitionUploadInfoEntity rEQRequisitionUploadInfoEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.REQRequisitionUploadInfo_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, "@RequisitionUploadInfoID", DbType.Int64, rEQRequisitionUploadInfoEntity.RequisitionUploadInfoID); db.AddInParameter(cmd, "@RequisitionID", DbType.Int64, rEQRequisitionUploadInfoEntity.RequisitionID); db.AddInParameter(cmd, "@Extension", DbType.String, rEQRequisitionUploadInfoEntity.Extension); db.AddInParameter(cmd, "@Remarks", DbType.String, rEQRequisitionUploadInfoEntity.Remarks); db.AddInParameter(cmd, "@Path", DbType.String, rEQRequisitionUploadInfoEntity.Path); db.AddInParameter(cmd, "@OriginalFileName", DbType.String, rEQRequisitionUploadInfoEntity.OriginalFileName); db.AddInParameter(cmd, "@CurrentFileName", DbType.String, rEQRequisitionUploadInfoEntity.CurrentFileName); db.AddInParameter(cmd, "@FileType", DbType.String, rEQRequisitionUploadInfoEntity.FileType); 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 SaveREQRequisitionUploadInfoEntity() { if (IsValid) { try { REQRequisitionUploadInfoEntity rEQRequisitionUploadInfoEntity = BuildREQRequisitionUploadInfoEntity(); Int64 result = -1; if (rEQRequisitionUploadInfoEntity.IsNew) { result = FCCREQRequisitionUploadInfo.GetFacadeCreate().Add(rEQRequisitionUploadInfoEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(REQRequisitionUploadInfoEntity.FLD_NAME_RequisitionUploadInfoID, rEQRequisitionUploadInfoEntity.RequisitionUploadInfoID.ToString(), SQLMatchType.Equal); result = FCCREQRequisitionUploadInfo.GetFacadeCreate().Update(rEQRequisitionUploadInfoEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _RequisitionUploadInfoID = 0; _REQRequisitionUploadInfoEntity = new REQRequisitionUploadInfoEntity(); PrepareInitialView(); BindREQRequisitionUploadInfoList(); if (rEQRequisitionUploadInfoEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "R EQRequisition Upload Info Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "R EQRequisition Upload Info Information has been updated successfully.", false); } } else { if (rEQRequisitionUploadInfoEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add R EQRequisition Upload Info Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update R EQRequisition Upload Info Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
protected void lvREQRequisitionUploadInfo_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 RequisitionUploadInfoID; Int64.TryParse(e.CommandArgument.ToString(), out RequisitionUploadInfoID); if (RequisitionUploadInfoID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _RequisitionUploadInfoID = RequisitionUploadInfoID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(REQRequisitionUploadInfoEntity.FLD_NAME_RequisitionUploadInfoID, RequisitionUploadInfoID.ToString(), SQLMatchType.Equal); REQRequisitionUploadInfoEntity rEQRequisitionUploadInfoEntity = new REQRequisitionUploadInfoEntity(); result = FCCREQRequisitionUploadInfo.GetFacadeCreate().Delete(rEQRequisitionUploadInfoEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _RequisitionUploadInfoID = 0; _REQRequisitionUploadInfoEntity = new REQRequisitionUploadInfoEntity(); PrepareInitialView(); BindREQRequisitionUploadInfoList(); MiscUtil.ShowMessage(lblMessage, "Requisition Upload Info has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete R EQRequisition Upload Info.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private Int64 Update(REQRequisitionUploadInfoEntity rEQRequisitionUploadInfoEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.REQRequisitionUploadInfo_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@RequisitionUploadInfoID", DbType.Int64, rEQRequisitionUploadInfoEntity.RequisitionUploadInfoID); Database.AddInParameter(cmd, "@RequisitionID", DbType.Int64, rEQRequisitionUploadInfoEntity.RequisitionID); Database.AddInParameter(cmd, "@Extension", DbType.String, rEQRequisitionUploadInfoEntity.Extension); Database.AddInParameter(cmd, "@Remarks", DbType.String, rEQRequisitionUploadInfoEntity.Remarks); Database.AddInParameter(cmd, "@Path", DbType.String, rEQRequisitionUploadInfoEntity.Path); Database.AddInParameter(cmd, "@OriginalFileName", DbType.String, rEQRequisitionUploadInfoEntity.OriginalFileName); Database.AddInParameter(cmd, "@CurrentFileName", DbType.String, rEQRequisitionUploadInfoEntity.CurrentFileName); Database.AddInParameter(cmd, "@FileType", DbType.String, rEQRequisitionUploadInfoEntity.FileType); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("REQRequisitionUploadInfoEntity already exists. Please specify another REQRequisitionUploadInfoEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("REQRequisitionUploadInfoEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("REQRequisitionUploadInfoEntity already exists. Please specify another REQRequisitionUploadInfoEntity."); } } } } return(returnCode); }
private void PrepareEditView() { REQRequisitionUploadInfoEntity rEQRequisitionUploadInfoEntity = CurrentREQRequisitionUploadInfoEntity; if (!rEQRequisitionUploadInfoEntity.IsNew) { if (ddlRequisitionID.Items.Count > 0 && rEQRequisitionUploadInfoEntity.RequisitionID != null) { ddlRequisitionID.SelectedValue = rEQRequisitionUploadInfoEntity.RequisitionID.ToString(); } txtExtension.Text = rEQRequisitionUploadInfoEntity.Extension.ToString(); txtRemarks.Text = rEQRequisitionUploadInfoEntity.Remarks.ToString(); txtPath.Text = rEQRequisitionUploadInfoEntity.Path.ToString(); txtOriginalFileName.Text = rEQRequisitionUploadInfoEntity.OriginalFileName.ToString(); txtCurrentFileName.Text = rEQRequisitionUploadInfoEntity.CurrentFileName.ToString(); txtFileType.Text = rEQRequisitionUploadInfoEntity.FileType.ToString(); btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
private REQRequisitionUploadInfoEntity BuildREQRequisitionUploadInfoEntity() { REQRequisitionUploadInfoEntity rEQRequisitionUploadInfoEntity = CurrentREQRequisitionUploadInfoEntity; if (ddlRequisitionID.Items.Count > 0) { if (ddlRequisitionID.SelectedValue == "0") { } else { rEQRequisitionUploadInfoEntity.RequisitionID = Int64.Parse(ddlRequisitionID.SelectedValue); } } rEQRequisitionUploadInfoEntity.Extension = txtExtension.Text.Trim(); rEQRequisitionUploadInfoEntity.Remarks = txtRemarks.Text.Trim(); rEQRequisitionUploadInfoEntity.Path = txtPath.Text.Trim(); rEQRequisitionUploadInfoEntity.OriginalFileName = txtOriginalFileName.Text.Trim(); rEQRequisitionUploadInfoEntity.CurrentFileName = txtCurrentFileName.Text.Trim(); rEQRequisitionUploadInfoEntity.FileType = txtFileType.Text.Trim(); return(rEQRequisitionUploadInfoEntity); }
Int64 IREQRequisitionUploadInfoFacade.Delete(REQRequisitionUploadInfoEntity rEQRequisitionUploadInfoEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateREQRequisitionUploadInfoDataAccess().Delete(rEQRequisitionUploadInfoEntity, filterExpression, option, reqTran)); }
Int64 IREQRequisitionUploadInfoFacade.Add(REQRequisitionUploadInfoEntity rEQRequisitionUploadInfoEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateREQRequisitionUploadInfoDataAccess().Add(rEQRequisitionUploadInfoEntity, option, reqTran)); }
protected void btnAddNew_Click(object sender, EventArgs e) { _RequisitionUploadInfoID = 0; _REQRequisitionUploadInfoEntity = new REQRequisitionUploadInfoEntity(); PrepareInitialView(); }