private void PrepareEditView() { PRMSupplierBrandMapEntity pRMSupplierBrandMapEntity = CurrentPRMSupplierBrandMapEntity; if (!pRMSupplierBrandMapEntity.IsNew) { if (ddlBrandID.Items.Count > 0 && pRMSupplierBrandMapEntity.BrandID != null) { ddlBrandID.SelectedValue = pRMSupplierBrandMapEntity.BrandID.ToString(); } if (ddlOriginRegionID.Items.Count > 0 && pRMSupplierBrandMapEntity.OriginRegionID != null) { ddlOriginRegionID.SelectedValue = pRMSupplierBrandMapEntity.OriginRegionID.ToString(); } if (ddlOriginRegionID.SelectedValue != "0") { MiscUtil.PopulateMDCountryByRegionID(ddlOriginCountryID, true, Int64.Parse(ddlOriginRegionID.SelectedValue)); } if (ddlOriginCountryID.Items.Count > 0 && pRMSupplierBrandMapEntity.OriginCountryID != null) { ddlOriginCountryID.SelectedValue = pRMSupplierBrandMapEntity.OriginCountryID.ToString(); } btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
Int64 IPRMSupplierBrandMapDataAccess.Add(PRMSupplierBrandMapEntity pRMSupplierBrandMapEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(pRMSupplierBrandMapEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(pRMSupplierBrandMapEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private void SavePRMSupplierBrandMapEntity() { if (IsValid) { try { PRMSupplierBrandMapEntity pRMSupplierBrandMapEntity = BuildPRMSupplierBrandMapEntity(); Int64 result = -1; if (pRMSupplierBrandMapEntity.IsNew) { result = FCCPRMSupplierBrandMap.GetFacadeCreate().Add(pRMSupplierBrandMapEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(PRMSupplierBrandMapEntity.FLD_NAME_SupplierBrandMapID, pRMSupplierBrandMapEntity.SupplierBrandMapID.ToString(), SQLMatchType.Equal); result = FCCPRMSupplierBrandMap.GetFacadeCreate().Update(pRMSupplierBrandMapEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _SupplierBrandMapID = 0; _PRMSupplierBrandMapEntity = new PRMSupplierBrandMapEntity(); PrepareInitialView(); BindPRMSupplierBrandMapList(); if (pRMSupplierBrandMapEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Vendor Brand Map Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "Vendor Brand Map Information has been updated successfully.", false); } } else { if (pRMSupplierBrandMapEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Vendor Brand Map Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Vendor Brand Map Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
private Int64 UpdateTran(PRMSupplierBrandMapEntity pRMSupplierBrandMapEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.PRMSupplierBrandMap_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, "@SupplierBrandMapID", DbType.Int64, pRMSupplierBrandMapEntity.SupplierBrandMapID); db.AddInParameter(cmd, "@SupplierID", DbType.Int64, pRMSupplierBrandMapEntity.SupplierID); db.AddInParameter(cmd, "@BrandID", DbType.Int64, pRMSupplierBrandMapEntity.BrandID); db.AddInParameter(cmd, "@OriginRegionID", DbType.Int64, pRMSupplierBrandMapEntity.OriginRegionID); db.AddInParameter(cmd, "@OriginCountryID", DbType.Int64, pRMSupplierBrandMapEntity.OriginCountryID); 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 lvPRMSupplierBrandMap_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 SupplierBrandMapID; Int64.TryParse(e.CommandArgument.ToString(), out SupplierBrandMapID); if (SupplierBrandMapID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _SupplierBrandMapID = SupplierBrandMapID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(PRMSupplierBrandMapEntity.FLD_NAME_SupplierBrandMapID, SupplierBrandMapID.ToString(), SQLMatchType.Equal); PRMSupplierBrandMapEntity pRMSupplierBrandMapEntity = new PRMSupplierBrandMapEntity(); result = FCCPRMSupplierBrandMap.GetFacadeCreate().Delete(pRMSupplierBrandMapEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _SupplierBrandMapID = 0; _PRMSupplierBrandMapEntity = new PRMSupplierBrandMapEntity(); PrepareInitialView(); BindPRMSupplierBrandMapList(); MiscUtil.ShowMessage(lblMessage, "Vendor Brand Map has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete Vendor Brand Map.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private PRMSupplierBrandMapEntity BuildPRMSupplierBrandMapEntity() { PRMSupplierBrandMapEntity pRMSupplierBrandMapEntity = CurrentPRMSupplierBrandMapEntity; pRMSupplierBrandMapEntity.SupplierID = this.OverviewSupplierID; if (ddlBrandID.Items.Count > 0) { if (ddlBrandID.SelectedValue == "0") { } else { pRMSupplierBrandMapEntity.BrandID = Int64.Parse(ddlBrandID.SelectedValue); } } if (ddlOriginRegionID.Items.Count > 0) { if (ddlOriginRegionID.SelectedValue == "0") { pRMSupplierBrandMapEntity.OriginRegionID = null; } else { pRMSupplierBrandMapEntity.OriginRegionID = Int64.Parse(ddlOriginRegionID.SelectedValue); } } if (ddlOriginCountryID.Items.Count > 0) { if (ddlOriginCountryID.SelectedValue == "0") { pRMSupplierBrandMapEntity.OriginCountryID = null; } else { pRMSupplierBrandMapEntity.OriginCountryID = Int64.Parse(ddlOriginCountryID.SelectedValue); } } return(pRMSupplierBrandMapEntity); }
private Int64 Update(PRMSupplierBrandMapEntity pRMSupplierBrandMapEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.PRMSupplierBrandMap_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@SupplierBrandMapID", DbType.Int64, pRMSupplierBrandMapEntity.SupplierBrandMapID); Database.AddInParameter(cmd, "@SupplierID", DbType.Int64, pRMSupplierBrandMapEntity.SupplierID); Database.AddInParameter(cmd, "@BrandID", DbType.Int64, pRMSupplierBrandMapEntity.BrandID); Database.AddInParameter(cmd, "@OriginRegionID", DbType.Int64, pRMSupplierBrandMapEntity.OriginRegionID); Database.AddInParameter(cmd, "@OriginCountryID", DbType.Int64, pRMSupplierBrandMapEntity.OriginCountryID); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("PRMSupplierBrandMapEntity already exists. Please specify another PRMSupplierBrandMapEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("PRMSupplierBrandMapEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("PRMSupplierBrandMapEntity already exists. Please specify another PRMSupplierBrandMapEntity."); } } } } return(returnCode); }
protected void btnAddNew_Click(object sender, EventArgs e) { _SupplierBrandMapID = 0; _PRMSupplierBrandMapEntity = new PRMSupplierBrandMapEntity(); PrepareInitialView(); }
Int64 IPRMSupplierBrandMapFacade.Delete(PRMSupplierBrandMapEntity pRMSupplierBrandMapEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreatePRMSupplierBrandMapDataAccess().Delete(pRMSupplierBrandMapEntity, filterExpression, option, reqTran)); }
Int64 IPRMSupplierBrandMapFacade.Add(PRMSupplierBrandMapEntity pRMSupplierBrandMapEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreatePRMSupplierBrandMapDataAccess().Add(pRMSupplierBrandMapEntity, option, reqTran)); }