public MST_CityENT SelectPK(SqlInt32 CityID) { try { SqlDatabase sqlDB = new SqlDatabase(myConnectionString); DbCommand dbCMD = sqlDB.GetStoredProcCommand("PR_MST_City_SelectByPK"); sqlDB.AddInParameter(dbCMD, "@CityID", SqlDbType.Int, CityID); MST_CityENT entMST_City = new MST_CityENT(); DataBaseHelper DBH = new DataBaseHelper(); using (IDataReader dr = DBH.ExecuteReader(sqlDB, dbCMD)) { while (dr.Read()) { if (!dr["CityID"].Equals(System.DBNull.Value)) { entMST_City.CityID = Convert.ToInt32(dr["CityID"]); } if (!dr["StateID"].Equals(System.DBNull.Value)) { entMST_City.StateID = Convert.ToInt32(dr["StateID"]); } if (!dr["CityName"].Equals(System.DBNull.Value)) { entMST_City.CityName = Convert.ToString(dr["CityName"]); } if (!dr["STDCode"].Equals(System.DBNull.Value)) { entMST_City.STDCode = Convert.ToString(dr["STDCode"]); } } } return(entMST_City); } catch (SqlException sqlex) { Message = SQLDataExceptionMessage(sqlex); if (SQLDataExceptionHandler(sqlex)) { throw; } return(null); } catch (Exception ex) { Message = ExceptionMessage(ex); if (ExceptionHandler(ex)) { throw; } return(null); } }
public Boolean Update(MST_CityENT entMST_City) { MST_CityDAL dalMST_City = new MST_CityDAL(); if (dalMST_City.Update(entMST_City)) { return(true); } else { this.Message = dalMST_City.Message; return(false); } }
public Boolean Insert(MST_CityENT entLOC_City) { MST_CityDAL dalLOC_City = new MST_CityDAL(); if (dalLOC_City.Insert(entLOC_City)) { return(true); } else { this.Message = dalLOC_City.Message; return(false); } }
public Boolean Insert(MST_CityENT entLOC_City) { try { SqlDatabase sqlDB = new SqlDatabase(myConnectionString); DbCommand dbCMD = sqlDB.GetStoredProcCommand("PR_LOC_City_Insert"); sqlDB.AddOutParameter(dbCMD, "@CityID", SqlDbType.Int, 4); sqlDB.AddInParameter(dbCMD, "@CityName", SqlDbType.VarChar, entLOC_City.CityName); sqlDB.AddInParameter(dbCMD, "@CreationDate", SqlDbType.DateTime, entLOC_City.CreationDate); DataBaseHelper DBH = new DataBaseHelper(); DBH.ExecuteNonQuery(sqlDB, dbCMD); entLOC_City.CityID = (SqlInt32)Convert.ToInt32(dbCMD.Parameters["@CityID"].Value); return(true); } catch (SqlException sqlex) { Message = SQLDataExceptionMessage(sqlex); if (SQLDataExceptionHandler(sqlex)) { throw; } return(false); } catch (Exception ex) { Message = ExceptionMessage(ex); if (ExceptionHandler(ex)) { throw; } return(false); } }
public Boolean Insert(MST_CityENT entMST_City) { try { SqlDatabase sqlDB = new SqlDatabase(myConnectionString); DbCommand dbCMD = sqlDB.GetStoredProcCommand("PR_MST_City_Insert"); sqlDB.AddInParameter(dbCMD, "@StateID", SqlDbType.Int, entMST_City.StateID); sqlDB.AddInParameter(dbCMD, "@CityName", SqlDbType.VarChar, entMST_City.CityName); sqlDB.AddInParameter(dbCMD, "@STDCode", SqlDbType.VarChar, entMST_City.STDCode); sqlDB.AddInParameter(dbCMD, "@CreationDate", SqlDbType.DateTime, entMST_City.CreationDate); sqlDB.AddInParameter(dbCMD, "@ModificationDate", SqlDbType.DateTime, entMST_City.ModificationDate); sqlDB.AddInParameter(dbCMD, "@UserID", SqlDbType.Int, entMST_City.UserID); DataBaseHelper DBH = new DataBaseHelper(); DBH.ExecuteNonQuery(sqlDB, dbCMD); return(true); } catch (SqlException sqlex) { Message = SQLDataExceptionMessage(sqlex); if (SQLDataExceptionHandler(sqlex)) { throw; } return(false); } catch (Exception ex) { Message = ExceptionMessage(ex); if (ExceptionHandler(ex)) { throw; } return(false); } }
private void FillControls(Int32 CityID) { //lblPageHeader.Text = CV.PageHeaderEdit + " City"; MST_CityBAL balMST_City = new MST_CityBAL(); MST_CityENT entMST_City = new MST_CityENT(); entMST_City = balMST_City.SelectPK(CityID); if (!entMST_City.CityName.IsNull) { txtCityName.Text = entMST_City.CityName.Value.ToString(); } if (!entMST_City.STDCode.IsNull) { txtSTDCode.Text = entMST_City.STDCode.Value.ToString(); } if (!entMST_City.StateID.IsNull) { ddlState.SelectedValue = entMST_City.StateID.Value.ToString(); } }
protected void btnAdd_Click(object sender, EventArgs e) { if (Request.QueryString["CityID"] == null) { MST_CityENT entMST_City = new MST_CityENT(); if (txtCityName.Text.ToString().Trim() != "") { entMST_City.CityName = txtCityName.Text.ToString().Trim(); } //if (txtPinCode.Text.ToString().Trim() != "") //{ // entMST_City.PinCode = txtPinCode.Text.ToString().Trim(); //} if (txtSTDCode.Text.ToString().Trim() != "") { entMST_City.STDCode = txtSTDCode.Text.ToString().Trim(); } if (ddlState.SelectedIndex > 0) { entMST_City.StateID = Convert.ToInt32(ddlState.SelectedValue); } entMST_City.CreationDate = DateTime.Now; entMST_City.ModificationDate = DateTime.Now; entMST_City.UserID = Convert.ToInt32(Session["UserID"]); MST_CityBAL balMST_City = new MST_CityBAL(); if (balMST_City.Insert(entMST_City)) { pnlAlert.Visible = true; lblMessage.Text = "Data Inserted Successfully."; ClearControls(); } } else { MST_CityENT entMST_City = new MST_CityENT(); if (txtCityName.Text.ToString().Trim() != "") { entMST_City.CityName = txtCityName.Text.ToString().Trim(); } //if (txtPinCode.Text.ToString().Trim() != "") //{ // entMST_City.PinCode = txtPinCode.Text.ToString().Trim(); //} if (txtSTDCode.Text.ToString().Trim() != "") { entMST_City.STDCode = txtSTDCode.Text.ToString().Trim(); } if (ddlState.SelectedIndex > 0) { entMST_City.StateID = Convert.ToInt32(ddlState.SelectedValue); } entMST_City.CityID = Convert.ToInt32(Request.QueryString["CityID"]); entMST_City.ModificationDate = DateTime.Now; entMST_City.UserID = Convert.ToInt32(Session["UserID"]); MST_CityBAL balMST_City = new MST_CityBAL(); if (balMST_City.Update(entMST_City)) { Response.Redirect("~/AdminPanel/Master/MST_City/MST_CityList.aspx"); } } }