/// <summary> /// To Get Live Rest Bud Villages By Id /// </summary> /// <param name="LivRestBudgID"></param> /// <returns></returns> public LiveRestBudVillagesList GetLiveRestBudVillagesById(int LivRestBudgID) { OracleConnection cnn = new OracleConnection(AppConfiguration.ConnectionString); OracleCommand cmd; string proc = "USP_TRN_GET_LIV_BUD_VILLG_BYID"; cmd = new OracleCommand(proc, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("liv_res_budgid_", LivRestBudgID); cmd.Parameters.Add("Sp_recordset", OracleDbType.RefCursor).Direction = ParameterDirection.Output; cmd.Connection.Open(); OracleDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); LiveRestBudVillagesBO oLiveRestBudVillagesBO = null; LiveRestBudVillagesList oLiveRestBudVillagesList = new LiveRestBudVillagesList(); while (dr.Read()) { oLiveRestBudVillagesBO = new LiveRestBudVillagesBO(); oLiveRestBudVillagesBO = MapData(dr); oLiveRestBudVillagesList.Add(oLiveRestBudVillagesBO); } dr.Close(); return(oLiveRestBudVillagesList); }
//get all data in mst_Concern table using USP_MST_SELECTCONCERN-SP /// <summary> /// To Get Live Rest Bud Villages /// </summary> /// <returns></returns> public LiveRestBudVillagesList GetLiveRestBudVillages() { OracleConnection cnn = new OracleConnection(con); OracleCommand cmd; string proc = "USP_TRN_GET_LIVRESBUD_VILLAGE"; cmd = new OracleCommand(proc, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("Sp_recordset", Oracle.DataAccess.Client.OracleDbType.RefCursor).Direction = ParameterDirection.Output; cmd.Connection.Open(); OracleDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); LiveRestBudVillagesBO objLiveRestBudVillagesBO = null; LiveRestBudVillagesList oLiveRestBudVillagesList = new LiveRestBudVillagesList(); while (dr.Read()) { objLiveRestBudVillagesBO = new LiveRestBudVillagesBO(); objLiveRestBudVillagesBO = MapData(dr); oLiveRestBudVillagesList.Add(objLiveRestBudVillagesBO); } dr.Close(); return(oLiveRestBudVillagesList); }
/// <summary> /// To Map Data /// </summary> /// <param name="reader"></param> /// <returns></returns> private LiveRestBudVillagesBO MapData(IDataReader reader) { LiveRestBudVillagesBO oLiveRestBudVillagesBO = new LiveRestBudVillagesBO(); if (ColumnExists(reader, "Liv_Res_BudgId") && !reader.IsDBNull(reader.GetOrdinal("Liv_Res_BudgId"))) { oLiveRestBudVillagesBO.Liv_Res_BudgId = Convert.ToInt32(reader.GetValue(reader.GetOrdinal("Liv_Res_BudgId"))); } if (ColumnExists(reader, "Village") && !reader.IsDBNull(reader.GetOrdinal("Village"))) { oLiveRestBudVillagesBO.Village = reader.GetString(reader.GetOrdinal("Village")); } return(oLiveRestBudVillagesBO); }
//save the data to mst_Concern table using USP_MST_INSERTCONCERN-SP public string AddLiveRestBudVillages(LiveRestBudVillagesBO oLiveRestBudVillagesBO) { string returnResult = string.Empty; LiveRestBudVillagesBO ooLiveRestBudVillagesBO = new LiveRestBudVillagesBO();//For Storing & Returning Result as Object OracleConnection OCon = new OracleConnection(con); OCon.Open(); OracleCommand oCmd = new OracleCommand("USP_TRN_INS_LIVRESBUD_VILLAGE", OCon); oCmd.CommandType = CommandType.StoredProcedure; int count = Convert.ToInt32(oCmd.CommandType); try { oCmd.Parameters.Add("Liv_Res_BudgId_", oLiveRestBudVillagesBO.Liv_Res_BudgId); oCmd.Parameters.Add("Village_", oLiveRestBudVillagesBO.Village); oCmd.Parameters.Add("CreatedBy_", oLiveRestBudVillagesBO.CreatedBy); oCmd.Parameters.Add("IsDeleted_", oLiveRestBudVillagesBO.IsDeleted); oCmd.Parameters.Add("errorMessage_", OracleDbType.Varchar2, 500).Direction = ParameterDirection.Output; oCmd.ExecuteNonQuery(); if (oCmd.Parameters["errorMessage_"].Value != null) { returnResult = oCmd.Parameters["errorMessage_"].Value.ToString(); } else { returnResult = string.Empty; } } catch { throw; } finally { oCmd.Dispose(); OCon.Close(); OCon.Dispose(); } return(returnResult); }
/// <summary> /// To Update Live Rest Bud Villages /// </summary> /// <param name="oLiveRestBudVillagesBO"></param> /// <returns></returns> public string UpdateLiveRestBudVillages(LiveRestBudVillagesBO oLiveRestBudVillagesBO) { string returnResult = string.Empty; cnn = new OracleConnection(con); proc = "USP_TRN_UPD_LIVRESBUD_VILLAGE"; cmd = new OracleCommand(proc, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Connection.Open(); cmd.Parameters.Add("Liv_Res_BudgId_", oLiveRestBudVillagesBO.Liv_Res_BudgId); cmd.Parameters.Add("Village_", oLiveRestBudVillagesBO.Village); cmd.Parameters.Add("updatedby_", oLiveRestBudVillagesBO.CreatedBy); cmd.Parameters.Add("IsDeleted_", oLiveRestBudVillagesBO.IsDeleted); cmd.Parameters.Add("errorMessage_", OracleDbType.Varchar2, 100).Direction = ParameterDirection.Output; try { cmd.ExecuteNonQuery(); if (cmd.Parameters["errorMessage_"].Value != null) { returnResult = cmd.Parameters["errorMessage_"].Value.ToString(); } else { returnResult = string.Empty; } } catch (Exception ex) { returnResult = string.Empty; throw ex; } return(returnResult); }
/// <summary> /// To Update Live Rest Bud Villages /// </summary> /// <param name="oLiveRestBudVillagesBO"></param> /// <returns></returns> public string UpdateLiveRestBudVillages(LiveRestBudVillagesBO oLiveRestBudVillagesBO) { oLiveRestBudVillagesDAL = new LiveRestBudVillagesDAL(); return(oLiveRestBudVillagesDAL.UpdateLiveRestBudVillages(oLiveRestBudVillagesBO)); }
/// <summary> /// To Add Live Rest Bud Villages /// </summary> /// <param name="oLiveRestBudVillagesBO"></param> /// <returns></returns> public string AddLiveRestBudVillages(LiveRestBudVillagesBO oLiveRestBudVillagesBO) { oLiveRestBudVillagesDAL = new LiveRestBudVillagesDAL(); return(oLiveRestBudVillagesDAL.AddLiveRestBudVillages(oLiveRestBudVillagesBO)); }
/// <summary> /// To Save And update Data /// </summary> private void AddLiveRestBudget() { LivelihoodRestBudgetBO oLiveRestBudgetBO = new LivelihoodRestBudgetBO(); LivelihoodRestBudgetBLL oLiveRestBudgetBLL = new LivelihoodRestBudgetBLL(); oLiveRestBudgetBO.IsDeleted = "False"; oLiveRestBudgetBO.CreatedBy = SessionUserId; oLiveRestBudgetBO.Liv_Bud_ItemID = Convert.ToInt32(ddlItem.SelectedValue.ToString()); oLiveRestBudgetBO.Liv_Bud_CategID = Convert.ToInt32(ddlCategory.SelectedValue.ToString()); //foreach( if (chklst.Items[0].Selected == true) { oLiveRestBudgetBO.ImplCost = "Yes"; } else { oLiveRestBudgetBO.ImplCost = "No"; } if (chklst.Items[1].Selected == true) { oLiveRestBudgetBO.OperCost = "Yes"; } else { oLiveRestBudgetBO.OperCost = "No"; } if (chklst.Items[2].Selected == true) { oLiveRestBudgetBO.ExternalMonitory = "Yes"; } else { oLiveRestBudgetBO.ExternalMonitory = "No"; } oLiveRestBudgetBO.NoOfBeneficial = Convert.ToDecimal(txtNoOfBeneficial.Text); oLiveRestBudgetBO.ItemQuantity = Convert.ToDecimal(txtItemQuantity.Text); oLiveRestBudgetBO.CostPerUnit = Convert.ToDecimal(txtCostPerUnit.Text); oLiveRestBudgetBO.TotalAmount = Convert.ToDecimal(txtTotal.Text); oLiveRestBudgetBO.Comments = txtComments.Text; oLiveRestBudgetBO.District = ddlDistrict.SelectedItem.Text; oLiveRestBudgetBO.County = ddlCounty.SelectedItem.Text; oLiveRestBudgetBO.SubCounty = ddlSubCounty.SelectedItem.Text; oLiveRestBudgetBO.Parish = ddlParish.SelectedItem.Text; oLiveRestBudgetBO.ProjectID = Convert.ToInt32(Session["PROJECT_ID"]); string AlertMessage = string.Empty; string retMessage = string.Empty; if (ViewStateLivRestBudgetID == 0) { //ADD SECTION string[] message = oLiveRestBudgetBLL.AddLiveRestBudget(oLiveRestBudgetBO); if (string.IsNullOrEmpty(message[0]) || message[0] == "" || message[0] == "null") { // message[0] = "Insertion Successfull"; if (!string.IsNullOrEmpty(message[1])) { LiveRestBudVillagesBLL oLiveRestBudVillagesBLL = new LiveRestBudVillagesBLL(); LiveRestBudVillagesBO oLiveRestBudVillagesBO = new LiveRestBudVillagesBO(); oLiveRestBudVillagesBO.IsDeleted = "False"; oLiveRestBudVillagesBO.CreatedBy = SessionUserId; oLiveRestBudVillagesBO.Liv_Res_BudgId = Convert.ToInt32(message[1]); for (int i = 0; i < lstbVillages.Items.Count; i++) { if (lstbVillages.Items[i].Selected) { oLiveRestBudVillagesBO.Village = lstbVillages.Items[i].Text; retMessage = oLiveRestBudVillagesBLL.AddLiveRestBudVillages(oLiveRestBudVillagesBO); } } if (string.IsNullOrEmpty(retMessage) || retMessage == "" || retMessage == "null") { retMessage = "Data saved successfully"; message[0] = "Data saved successfully"; } } } } else { //UPDATE SECTION if (ViewStateLivRestBudgetID > 0) { oLiveRestBudgetBO.Liv_Res_BudgID = ViewStateLivRestBudgetID; oLiveRestBudgetBO.UpdatedBy = SessionUserId; oLiveRestBudgetBO.CreatedBy = SessionUserId; retMessage = oLiveRestBudgetBLL.UpdateLiveRestBudget(oLiveRestBudgetBO); if (string.IsNullOrEmpty(retMessage) || retMessage == "" || retMessage == "null") { LiveRestBudVillagesBLL oLiveRestBudVillagesBLL = new LiveRestBudVillagesBLL(); LiveRestBudVillagesBO oLiveRestBudVillagesBO = new LiveRestBudVillagesBO(); oLiveRestBudVillagesBO.IsDeleted = "False"; oLiveRestBudVillagesBO.CreatedBy = SessionUserId; oLiveRestBudVillagesBO.Liv_Res_BudgId = ViewStateLivRestBudgetID; //DELETE & INSERT CONCEPT oLiveRestBudVillagesBLL.DeleteLiveRestBudVillages(ViewStateLivRestBudgetID); //DELETE for (int i = 0; i < lstbVillages.Items.Count; i++) { if (lstbVillages.Items[i].Selected) { oLiveRestBudVillagesBO.Village = lstbVillages.Items[i].Text; retMessage = oLiveRestBudVillagesBLL.UpdateLiveRestBudVillages(oLiveRestBudVillagesBO); //INSERT } } retMessage = "Data updated successfully"; } } } ClearFields(); BindGrid(); AlertMessage = "alert('" + retMessage + "');"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true); }