Int64 ICRMBuyerAllotteeDataAccess.Add(CRMBuyerAllotteeEntity cRMBuyerAllotteeEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(cRMBuyerAllotteeEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(cRMBuyerAllotteeEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private void SaveCRMBuyerAllotteeEntity() { if (IsValid) { try { CRMBuyerAllotteeEntity cRMBuyerAllotteeEntity = BuildCRMBuyerAllotteeEntity(); Int64 result = -1; if (cRMBuyerAllotteeEntity.IsNew) { result = FCCCRMBuyerAllottee.GetFacadeCreate().Add(cRMBuyerAllotteeEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(CRMBuyerAllotteeEntity.FLD_NAME_BuyerAllotteeID, cRMBuyerAllotteeEntity.BuyerAllotteeID.ToString(), SQLMatchType.Equal); result = FCCCRMBuyerAllottee.GetFacadeCreate().Update(cRMBuyerAllotteeEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _BuyerAllotteeID = 0; _CRMBuyerAllotteeEntity = new CRMBuyerAllotteeEntity(); PrepareInitialView(); BindCRMBuyerAllotteeList(); if (cRMBuyerAllotteeEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Buyer Allottee Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "Buyer Allottee Information has been updated successfully.", false); } } else { if (cRMBuyerAllotteeEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Buyer Allottee Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Buyer Allottee Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
private Int64 Update(CRMBuyerAllotteeEntity cRMBuyerAllotteeEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CRMBuyerAllottee_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@BuyerAllotteeID", DbType.Int64, cRMBuyerAllotteeEntity.BuyerAllotteeID); Database.AddInParameter(cmd, "@BuyerBasicInfoID", DbType.Int64, cRMBuyerAllotteeEntity.BuyerBasicInfoID); Database.AddInParameter(cmd, "@OwnerFullName", DbType.String, cRMBuyerAllotteeEntity.OwnerFullName); Database.AddInParameter(cmd, "@ImageUrl", DbType.String, cRMBuyerAllotteeEntity.ImageUrl); Database.AddInParameter(cmd, "@OwnPercentage", DbType.Decimal, cRMBuyerAllotteeEntity.OwnPercentage); Database.AddInParameter(cmd, "@MobileNo", DbType.String, cRMBuyerAllotteeEntity.MobileNo); Database.AddInParameter(cmd, "@LandPhone", DbType.String, cRMBuyerAllotteeEntity.LandPhone); Database.AddInParameter(cmd, "@PresentAddress", DbType.String, cRMBuyerAllotteeEntity.PresentAddress); Database.AddInParameter(cmd, "@FatherName", DbType.String, cRMBuyerAllotteeEntity.FatherName); Database.AddInParameter(cmd, "@MotherName", DbType.String, cRMBuyerAllotteeEntity.MotherName); Database.AddInParameter(cmd, "@SpouseName", DbType.String, cRMBuyerAllotteeEntity.SpouseName); Database.AddInParameter(cmd, "@TINNumber", DbType.String, cRMBuyerAllotteeEntity.TINNumber); Database.AddInParameter(cmd, "@DateOfBirth", DbType.DateTime, cRMBuyerAllotteeEntity.DateOfBirth); Database.AddInParameter(cmd, "@Email", DbType.String, cRMBuyerAllotteeEntity.Email); Database.AddInParameter(cmd, "@BusinessDetails", DbType.String, cRMBuyerAllotteeEntity.BusinessDetails); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("CRMBuyerAllotteeEntity already exists. Please specify another CRMBuyerAllotteeEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("CRMBuyerAllotteeEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("CRMBuyerAllotteeEntity already exists. Please specify another CRMBuyerAllotteeEntity."); } } } } return(returnCode); }
protected void lvCRMBuyerAllottee_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 BuyerAllotteeID; Int64.TryParse(e.CommandArgument.ToString(), out BuyerAllotteeID); if (BuyerAllotteeID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _BuyerAllotteeID = BuyerAllotteeID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(CRMBuyerAllotteeEntity.FLD_NAME_BuyerAllotteeID, BuyerAllotteeID.ToString(), SQLMatchType.Equal); CRMBuyerAllotteeEntity cRMBuyerAllotteeEntity = new CRMBuyerAllotteeEntity(); result = FCCCRMBuyerAllottee.GetFacadeCreate().Delete(cRMBuyerAllotteeEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _BuyerAllotteeID = 0; _CRMBuyerAllotteeEntity = new CRMBuyerAllotteeEntity(); PrepareInitialView(); BindCRMBuyerAllotteeList(); MiscUtil.ShowMessage(lblMessage, "C RMBuyer Allottee has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete C RMBuyer Allottee.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private Int64 DeleteTran(CRMBuyerAllotteeEntity cRMBuyerAllotteeEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CRMBuyerAllottee_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); }
private Int64 Delete(CRMBuyerAllotteeEntity cRMBuyerAllotteeEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CRMBuyerAllottee_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("CRMBuyerAllotteeEntity already exists. Please specify another CRMBuyerAllotteeEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("CRMBuyerAllotteeEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("CRMBuyerAllotteeEntity already exists. Please specify another CRMBuyerAllotteeEntity."); } } } } return(returnCode); }
private void PrepareEditView() { CRMBuyerAllotteeEntity cRMBuyerAllotteeEntity = CurrentCRMBuyerAllotteeEntity; if (!cRMBuyerAllotteeEntity.IsNew) { txtOwnerFullName.Text = cRMBuyerAllotteeEntity.OwnerFullName.ToString(); txtOwnPercentage.Text = cRMBuyerAllotteeEntity.OwnPercentage.ToString(); txtMobileNo.Text = cRMBuyerAllotteeEntity.MobileNo.ToString(); txtLandPhone.Text = cRMBuyerAllotteeEntity.LandPhone.ToString(); txtPresentAddress.Text = cRMBuyerAllotteeEntity.PresentAddress.ToString(); txtFatherName.Text = cRMBuyerAllotteeEntity.FatherName.ToString(); txtMotherName.Text = cRMBuyerAllotteeEntity.MotherName.ToString(); txtSpouseName.Text = cRMBuyerAllotteeEntity.SpouseName.ToString(); txtTINNumber.Text = cRMBuyerAllotteeEntity.TINNumber.ToString(); txtDateOfBirth.Text = cRMBuyerAllotteeEntity.DateOfBirth.ToStringDefault(); txtEmail.Text = cRMBuyerAllotteeEntity.Email.ToString(); txtBusinessDetails.Text = cRMBuyerAllotteeEntity.BusinessDetails.ToString(); btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
private Int64 UpdateTran(CRMBuyerAllotteeEntity cRMBuyerAllotteeEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.CRMBuyerAllottee_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, "@BuyerAllotteeID", DbType.Int64, cRMBuyerAllotteeEntity.BuyerAllotteeID); db.AddInParameter(cmd, "@BuyerBasicInfoID", DbType.Int64, cRMBuyerAllotteeEntity.BuyerBasicInfoID); db.AddInParameter(cmd, "@OwnerFullName", DbType.String, cRMBuyerAllotteeEntity.OwnerFullName); db.AddInParameter(cmd, "@ImageUrl", DbType.String, cRMBuyerAllotteeEntity.ImageUrl); db.AddInParameter(cmd, "@OwnPercentage", DbType.Decimal, cRMBuyerAllotteeEntity.OwnPercentage); db.AddInParameter(cmd, "@MobileNo", DbType.String, cRMBuyerAllotteeEntity.MobileNo); db.AddInParameter(cmd, "@LandPhone", DbType.String, cRMBuyerAllotteeEntity.LandPhone); db.AddInParameter(cmd, "@PresentAddress", DbType.String, cRMBuyerAllotteeEntity.PresentAddress); db.AddInParameter(cmd, "@FatherName", DbType.String, cRMBuyerAllotteeEntity.FatherName); db.AddInParameter(cmd, "@MotherName", DbType.String, cRMBuyerAllotteeEntity.MotherName); db.AddInParameter(cmd, "@SpouseName", DbType.String, cRMBuyerAllotteeEntity.SpouseName); db.AddInParameter(cmd, "@TINNumber", DbType.String, cRMBuyerAllotteeEntity.TINNumber); db.AddInParameter(cmd, "@DateOfBirth", DbType.DateTime, cRMBuyerAllotteeEntity.DateOfBirth); db.AddInParameter(cmd, "@Email", DbType.String, cRMBuyerAllotteeEntity.Email); db.AddInParameter(cmd, "@BusinessDetails", DbType.String, cRMBuyerAllotteeEntity.BusinessDetails); 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); }
Int64 ICRMBuyerAllotteeFacade.Delete(CRMBuyerAllotteeEntity cRMBuyerAllotteeEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateCRMBuyerAllotteeDataAccess().Delete(cRMBuyerAllotteeEntity, filterExpression, option, reqTran)); }
Int64 ICRMBuyerAllotteeFacade.Add(CRMBuyerAllotteeEntity cRMBuyerAllotteeEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateCRMBuyerAllotteeDataAccess().Add(cRMBuyerAllotteeEntity, option, reqTran)); }
protected void btnAddNew_Click(object sender, EventArgs e) { _BuyerAllotteeID = 0; _CRMBuyerAllotteeEntity = new CRMBuyerAllotteeEntity(); PrepareInitialView(); }
private CRMBuyerAllotteeEntity BuildCRMBuyerAllotteeEntity() { CRMBuyerAllotteeEntity cRMBuyerAllotteeEntity = CurrentCRMBuyerAllotteeEntity; cRMBuyerAllotteeEntity.BuyerBasicInfoID = CRMBuyerBasicInfoID; cRMBuyerAllotteeEntity.OwnerFullName = txtOwnerFullName.Text.Trim(); String ImageUrlpath; if (fuImageUrl.HasFile == true && cRMBuyerAllotteeEntity.ImageUrl.IsNotNullOrEmpty()) { if (File.Exists(Server.MapPath(cRMBuyerAllotteeEntity.ImageUrl))) { File.Delete(Server.MapPath(cRMBuyerAllotteeEntity.ImageUrl)); } ImageUrlpath = FileUploadConstants.CRM.Buyer + Guid.NewGuid() + fuImageUrl.FileName; fuImageUrl.SaveAs(Server.MapPath(ImageUrlpath)); cRMBuyerAllotteeEntity.ImageUrl = ImageUrlpath; } if (cRMBuyerAllotteeEntity.ImageUrl.IsNotNullOrEmpty() && fuImageUrl.HasFile == false) { cRMBuyerAllotteeEntity.ImageUrl = cRMBuyerAllotteeEntity.ImageUrl; } if (fuImageUrl.HasFile == false && cRMBuyerAllotteeEntity.ImageUrl.IsNullOrEmpty()) { cRMBuyerAllotteeEntity.ImageUrl = null; } if (fuImageUrl.HasFile == true && cRMBuyerAllotteeEntity.ImageUrl.IsNullOrEmpty()) { ImageUrlpath = FileUploadConstants.CRM.Buyer + Guid.NewGuid() + fuImageUrl.FileName; fuImageUrl.SaveAs(Server.MapPath(ImageUrlpath)); cRMBuyerAllotteeEntity.ImageUrl = ImageUrlpath; } if (!txtOwnPercentage.Text.Trim().IsNullOrEmpty()) { cRMBuyerAllotteeEntity.OwnPercentage = Decimal.Parse(txtOwnPercentage.Text.Trim()); } else { cRMBuyerAllotteeEntity.OwnPercentage = null; } cRMBuyerAllotteeEntity.MobileNo = txtMobileNo.Text.Trim(); cRMBuyerAllotteeEntity.LandPhone = txtLandPhone.Text.Trim(); cRMBuyerAllotteeEntity.PresentAddress = txtPresentAddress.Text.Trim(); cRMBuyerAllotteeEntity.FatherName = txtFatherName.Text.Trim(); cRMBuyerAllotteeEntity.MotherName = txtMotherName.Text.Trim(); cRMBuyerAllotteeEntity.SpouseName = txtSpouseName.Text.Trim(); cRMBuyerAllotteeEntity.TINNumber = txtTINNumber.Text.Trim(); if (txtDateOfBirth.Text.Trim().IsNotNullOrEmpty()) { cRMBuyerAllotteeEntity.DateOfBirth = MiscUtil.ParseToDateTime(txtDateOfBirth.Text); } else { cRMBuyerAllotteeEntity.DateOfBirth = null; } cRMBuyerAllotteeEntity.Email = txtEmail.Text.Trim(); cRMBuyerAllotteeEntity.BusinessDetails = txtBusinessDetails.Text.Trim(); return(cRMBuyerAllotteeEntity); }