public void BindDDL() { DataTable dtAdvertiser = AdvertiserClass.GetAllAdvertiser(); if (dtAdvertiser.Rows.Count > 0) { ddlAdvertise.DataTextField = "AdvertiserName"; ddlAdvertise.DataValueField = "AdvertiserIDP"; ddlAdvertise.DataSource = dtAdvertiser; ddlAdvertise.DataBind(); ddlAdvertise.Items.Insert(0, new ListItem("--Select State--", "-1")); ddlAdvertise.SelectedIndex = 0; } DataTable dtPlan = PlanClass.GetAllPlan(); if (dtPlan.Rows.Count > 0) { ddlAdvertisePlan.DataTextField = "PlanTitle"; ddlAdvertisePlan.DataValueField = "PlanIDP"; ddlAdvertisePlan.DataSource = dtPlan; ddlAdvertisePlan.DataBind(); ddlAdvertisePlan.Items.Insert(0, new ListItem("--Select State--", "-1")); ddlAdvertisePlan.SelectedIndex = 0; } }
private void SetPlansA() { var c1 = SchoolContext.Classes.FirstOrDefault(x => x.Litera == 'a'); var p1 = new PlanClass() { Id = Guid.NewGuid().ToString(), Class = c1, }; p1.SubjectPlans.Add(new SubjectPlan { Count = 2, Subject = SchoolContext.Subjects.First(x => x.Name == "Biology") }); p1.SubjectPlans.Add(new SubjectPlan { Count = 1, Subject = SchoolContext.Subjects.First(x => x.Name == "Literatura") }); p1.SubjectPlans.Add(new SubjectPlan { Count = 3, Subject = SchoolContext.Subjects.First(x => x.Name == "It") }); SchoolContext.Add(p1); SchoolContext.SaveChanges(); }
private void EditPlanButton_Click(object sender, EventArgs e) { PlanForm form = new PlanForm(); PlanClass formClass = new PlanClass(menu.Id, menu, form); form.SetClass(formClass); form.Show(); }
protected void btSave_Click(object sender, EventArgs e) { PlanClass obj = new PlanClass(); obj.PlanTitle = tbPlanTitle.Text; Int32 mPlanID = 0; Int64 mCityIDF = 0, mStateIDF = 0; float mPlanAmount = 0; float.TryParse(tbPlanAmount.Text, out mPlanAmount); Int32.TryParse(ddlPlanTypeID.SelectedValue, out mPlanID); Int64.TryParse(ddlCity.SelectedValue, out mCityIDF); Int64.TryParse(ddlState.SelectedValue, out mStateIDF); obj.PlanTypeID = mPlanID; obj.CityIDF = mCityIDF; obj.StateIDF = mStateIDF; obj.PlanAmount = mPlanAmount; obj.IsActive = cbIsActive.Checked; MEMBERS.SQLReturnValue mRes; if (hfID.Value == string.Empty) { obj.Flag = "ADD"; mRes = PlanClass.Insert_Update_Plan(obj); } else { obj.Flag = "EDIT"; obj.PlanIDP = Int64.Parse(hfID.Value); mRes = PlanClass.Insert_Update_Plan(obj); } ScriptManager.RegisterStartupScript(this, this.GetType(), "noti", "setMessage('<b>" + mRes.MessageFromSQL + "</b>',1);", true); ClearControls(); BindData(); pnC.Visible = false; pnG.Visible = true; btAddNew.Visible = true; }
protected void rptData_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandArgument != null) { Int64 PlanIDP = Int64.Parse(e.CommandArgument.ToString()); switch (e.CommandName) { case "cEdit": hfID.Value = PlanIDP.ToString(); DataTable dtGetPlan = PlanClass.GetPlan_ByPlanID(PlanIDP); if (dtGetPlan.Rows.Count > 0) { DataRow dr = dtGetPlan.Rows[0]; tbPlanTitle.Text = dr["PlanTitle"].ToString(); ddlPlanTypeID.SelectedValue = dr["PlanTypeID"].ToString(); ddlCity.SelectedValue = (dr["CityIDF"].ToString() == "0" ? "-1" : dr["CityIDF"].ToString()); ddlState.SelectedValue = (dr["StateIDF"].ToString() == "0" ? "-1" : dr["StateIDF"].ToString()); tbPlanAmount.Text = dr["PlanAmount"].ToString(); cbIsActive.Checked = bool.Parse(dr["IsActive"].ToString()); pnC.Visible = true; pnG.Visible = false; btAddNew.Visible = false; } break; case "cDelete": MEMBERS.SQLReturnValue mRes = PlanClass.DeletePlan_ByPlanID(PlanIDP); ScriptManager.RegisterStartupScript(this, this.GetType(), "noti", "setMessage('<b>" + mRes.MessageFromSQL + "</b>',1);", true); ClearControls(); BindData(); break; } } }
public void BindData() { rptData.DataSource = PlanClass.GetAllPlan(); rptData.DataBind(); }
public void SetClass(PlanClass someClass) => activeClass = someClass;