/// <summary> /// Gets Companies /// </summary> private void GetCompanies() { DropDownListCompany.DataSource = DataProvider.GetCompanies(); DropDownListCompany.DataTextField = "COMPANY_NAME"; DropDownListCompany.DataValueField = "COMPANY_ID"; DropDownListCompany.DataBind(); }
private void BindCompany() { DropDownListCompany.DataSource = Company.GetCompanyList(); DropDownListCompany.DataTextField = "Description"; DropDownListCompany.DataValueField = "CompanyId"; DropDownListCompany.DataBind(); DropDownListCompany.Items.Insert(0, new ListItem("Please select", "0")); }
protected void Page_Load(object sender, EventArgs e) { if ((string)Session["userType"] == Reference.USR_ADM) { divCompany.Visible = true; DropDownListCompany.Visible = true; // int companyID = Convert.ToInt32(DropDownListCompany.SelectedItem.Value); } else { // User userObj = new User(); // UserManagement uDao = new UserManagement(); divCompany.Visible = false; DropDownListCompany.Visible = false; // userObj = uDao.getUserByID(Session["userID"].ToString()); // int companyID = userObj.CompanyID; } //BillboardSearch.Attributes.Add("onClick", "return false;"); if (!Page.IsPostBack) { Database db = new Database(); string mainconn = ConfigurationManager.ConnectionStrings["Targeted_Marketing_DisplayConnectionString"].ConnectionString; SqlConnection sqlconn = new SqlConnection(Reference.Constr); string sqlquery = "SELECT * FROM [CodeReferece] WHERE ([CodeType] = @CodeType)"; SqlCommand cmd = new SqlCommand(sqlquery, sqlconn); cmd.Parameters.AddWithValue("@CodeType", "Category"); SqlDataAdapter sda = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); sda.Fill(dt); CheckBoxList1.DataSource = dt; CheckBoxList1.DataBind(); SqlCommand cmdCompany = new SqlCommand("Select * from Company where status=1"); DataTable dtCompany = db.getDataTable(cmdCompany); DropDownListCompany.DataSource = dtCompany; DropDownListCompany.DataValueField = "CompanyID"; DropDownListCompany.DataTextField = "Name"; DropDownListCompany.DataBind(); DropDownListCompany.Items.Insert(0, new ListItem("---Select A Company---", "0")); } CompareValidator1.ValueToCompare = DateTime.Now.ToShortDateString(); CompareValidator2.ValueToCompare = DateTime.Now.ToShortDateString(); if (FileUpload1.HasFile) { Literal1.Text = Convert.ToString(FileUpload1.PostedFile.FileName); if (Literal1.Text.EndsWith(".png") || Literal1.Text.EndsWith(".jpg") || Literal1.Text.EndsWith(".jpeg") || Literal1.Text.EndsWith(".gif") || Literal1.Text.EndsWith(".PNG") || Literal1.Text.EndsWith(".JPG") || Literal1.Text.EndsWith(".JPEG") || Literal1.Text.EndsWith(".GIF")) { Literal2.Text = "image"; } else { Literal2.Text = "video"; } } }
private void LoadCompanies() { List <Company> listCompanies = company.LoadCompanies(_x, "Ramais", "Empresa").ToList(); listCompanies.Insert(0, new Company()); DropDownListCompany.DataSource = listCompanies; DropDownListCompany.DataBind(); }
protected void UpdateDropDownListCompany() { SqlConnection conn = new SqlConnection(dbconfig); SqlDataAdapter da = null; DataSet ds = null; DataTable dt = null; string sqlsel = "SELECT IdCompany, Name FROM Company"; try { // conn.Open(); SqlDataAdapter open the connection by itself da = new SqlDataAdapter(); da.SelectCommand = new SqlCommand(sqlsel, conn); ds = new DataSet(); da.Fill(ds, "Company"); dt = ds.Tables["Company"]; // populate the dropdownlist DropDownListCompany.Items.Clear(); DropDownListCompany.DataSource = dt; DropDownListCompany.DataTextField = "Name"; DropDownListCompany.DataValueField = "IdCompany"; DropDownListCompany.DataBind(); DropDownListCompany.Items.Insert(0, "Select a company"); //Select the Company of the selected product string company = GridViewProduct.SelectedRow.Cells[6].Text; DropDownListCompany.Items.FindByValue(company).Selected = true; } catch (Exception ex) { LabelMessageProduct.Text = ex.Message; } finally { // SqlDataAdapter closes the connection by itself, but can fail in case of errors conn.Close(); } }
protected void UpdateDropDownListCompany() { // Create a db connection with configuration from web.config SqlConnection conn = new SqlConnection(dbconfig); //SqlConnection conn = new SqlConnection(@"data source = .\SQLEXPRESS; integrated security = true; database = CMSdb"); SqlDataAdapter da = null; DataSet ds = null; DataTable dt = null; string sqlsel = "SELECT IdCompany, Name FROM Company"; try { // conn.Open(); SqlDataAdapter open the connection by itself da = new SqlDataAdapter(); da.SelectCommand = new SqlCommand(sqlsel, conn); ds = new DataSet(); da.Fill(ds, "Company"); dt = ds.Tables["Company"]; // populate the dropdownlist DropDownListCompany.Items.Clear(); DropDownListCompany.DataSource = dt; DropDownListCompany.DataTextField = "Name"; DropDownListCompany.DataValueField = "IdCompany"; DropDownListCompany.DataBind(); DropDownListCompany.Items.Insert(0, "Select a company"); } catch (Exception ex) { LabelMessageProduct.Text = ex.Message; } finally { // SqlDataAdapter closes the connection by itself, but can fail in case of errors conn.Close(); } }
protected void Page_Load(object sender, EventArgs e) { //login_div.Attributes.Add("style","display:none"); Advertisement adObject = new Advertisement(); Advertisement_Management adObjectClass = new Advertisement_Management(); adObject = adObjectClass.getAdvByID(Session["AdvertID"].ToString()); string previousimagepath = adObject.Item.ToString(); if (adObject.ItemType == "image") { imgLogo.Attributes.Add("style", "display:block"); videoDog.Attributes.Add("style", "display:none"); imgLogo.Visible = true; videoDog.Visible = false; imgLogo.ImageUrl = ResolveUrl(previousimagepath); } if (adObject.ItemType == "video") { imgLogo.Attributes.Add("style", "display:none"); videoDog.Attributes.Add("style", "display:block"); videoDog.Visible = true; imgLogo.Visible = false; videoDog.Src = ResolveUrl(previousimagepath); } SqlConnection conn = null; SqlDataReader reader = null; conn = new SqlConnection(Reference.Constr); conn.Open(); if ((string)Session["userType"] == Reference.USR_ADM) { divCompany.Visible = true; DropDownListCompany.Visible = true; // int companyID = Convert.ToInt32(DropDownListCompany.SelectedItem.Value); } else { // User userObj = new User(); // UserManagement uDao = new UserManagement(); divCompany.Visible = false; DropDownListCompany.Visible = false; // userObj = uDao.getUserByID(Session["userID"].ToString()); // int companyID = userObj.CompanyID; } if (FileUpload1.HasFile) { Literal1.Text = Convert.ToString(FileUpload1.PostedFile.FileName); if (Literal1.Text.EndsWith(".png") || Literal1.Text.EndsWith(".jpg") || Literal1.Text.EndsWith(".jpeg") || Literal1.Text.EndsWith(".gif") || Literal1.Text.EndsWith(".PNG") || Literal1.Text.EndsWith(".JPG") || Literal1.Text.EndsWith(".JPEG") || Literal1.Text.EndsWith(".GIF")) { Literal2.Text = "image"; } else { Literal2.Text = "video"; } } if (!Page.IsPostBack) { //SqlCommand cmdBB = new SqlCommand("SELECT BillboardID,BillboardCode, Latitude ,Longtitude ,(( AddressLn1)" + // " + ' '+( AddressLn2 )+ ' '+(City)+ ', '+(Country)+ ' '+(postalCode)) AS Address FROM BillboardLocation where status=1", conn); //SqlDataAdapter sdaBB = new SqlDataAdapter(); //DataTable dtBB = new DataTable(); //cmdBB.Connection = conn; //sdaBB.SelectCommand = cmdBB; //sdaBB.Fill(dtBB); //GridView1.DataSource = dtBB; //GridView1.DataBind(); Database db = new Database(); string mainconn = ConfigurationManager.ConnectionStrings["Targeted_Marketing_DisplayConnectionString"].ConnectionString; SqlConnection sqlconn = new SqlConnection(Reference.Constr); string sqlquery = "SELECT * FROM [CodeReferece] WHERE ([CodeType] = @CodeType)"; SqlCommand cmdCodeRef = new SqlCommand(sqlquery, sqlconn); cmdCodeRef.Parameters.AddWithValue("@CodeType", "Category"); SqlDataAdapter sdaCodeRef = new SqlDataAdapter(cmdCodeRef); DataTable dt = new DataTable(); sdaCodeRef.Fill(dt); CheckBoxList1.DataSource = dt; CheckBoxList1.DataBind(); SqlCommand cmdCompany = new SqlCommand("Select * from Company where status=1"); DataTable dtCompany = db.getDataTable(cmdCompany); DropDownListCompany.DataSource = dtCompany; DropDownListCompany.DataValueField = "CompanyID"; DropDownListCompany.DataTextField = "Name"; DropDownListCompany.DataBind(); DropDownListCompany.Items.Insert(0, new ListItem("---Select A Company---", "0")); Advertisement AdvertObj = new Advertisement(); Advertisement_Management aDao = new Advertisement_Management(); AdvertObj = aDao.getAdvByID(Session["AdvertID"].ToString()); DateTime startDatevar = Convert.ToDateTime(AdvertObj.StartDate); String ConvertDate = startDatevar.ToString("yyyy-MM-dd"); DateTime dt2 = Convert.ToDateTime(AdvertObj.EndDate); String ConvertEndDate = dt2.ToString("yyyy-MM-dd"); AdvIDLabel.Text = " for " + ' ' + AdvertObj.Name.ToString(); startDateTB.Text = ConvertDate; endDateTB.Text = ConvertEndDate; DropDownListCompany.SelectedValue = AdvertObj.CompanyID.ToString(); adNameTB.Text = AdvertObj.Name.ToString(); videoDurationTB.Text = AdvertObj.Duration.ToString(); SqlCommand cmd = new SqlCommand("select * from [AdvertisementAudience] where AdvID=@ID", conn); SqlParameter param = new SqlParameter(); param.ParameterName = "@ID"; param.Value = Session["AdvertID"].ToString(); cmd.Parameters.Add(param); SqlDataAdapter sda = new SqlDataAdapter(); DataTable datatable = new DataTable(); cmd.Connection = conn; sda.SelectCommand = cmd; sda.Fill(datatable); cmd.Parameters.Clear(); // string userName = dtLoginTable.Rows[0]["UserName"].ToString(); string AgeID = datatable.Rows[0]["AgeID"].ToString(); for (int i = 0; i < datatable.Rows.Count; i++) { int ageChecker = Convert.ToInt32(datatable.Rows[i]["AgeID"]); string GenderChecker = datatable.Rows[i]["GenderID"].ToString(); if (ageChecker == 1) { if (GenderChecker == "M") { CheckBoxList2.Items[0].Selected = true; } else { CheckBoxList2.Items[4].Selected = true; } } if (ageChecker == 2) { if (GenderChecker == "M") { CheckBoxList2.Items[1].Selected = true; } else { CheckBoxList2.Items[5].Selected = true; } } if (ageChecker == 3) { if (GenderChecker == "M") { CheckBoxList2.Items[2].Selected = true; } else { CheckBoxList2.Items[6].Selected = true; } } if (ageChecker == 4) { if (GenderChecker == "M") { CheckBoxList2.Items[3].Selected = true; } else { CheckBoxList2.Items[7].Selected = true; } } } CompareValidator2.ValueToCompare = DateTime.Now.ToShortDateString(); SqlCommand cmdLoc = new SqlCommand("select a.AdvID,a.BillboardID,b.BillboardCode from AdvertisementLocation a inner join BillboardLocation b on a.BillboardID = b.BillboardID where a.AdvID = @ID", conn); SqlParameter paramLoc = new SqlParameter(); paramLoc.ParameterName = "@ID"; paramLoc.Value = Session["AdvertID"].ToString(); cmdLoc.Parameters.Add(paramLoc); SqlDataAdapter sdaLoc = new SqlDataAdapter(); DataTable datatableLoc = new DataTable(); cmdLoc.Connection = conn; sdaLoc.SelectCommand = cmdLoc; sdaLoc.Fill(datatableLoc); cmdLoc.Parameters.Clear(); for (int i = 0; i < datatableLoc.Rows.Count; i++) { string BillboardCodefromdb = datatableLoc.Rows[i]["BillboardCode"].ToString(); foreach (GridViewRow gvr in GridView1.Rows) { if (gvr.RowType == DataControlRowType.DataRow) { CheckBox cb = (CheckBox)(gvr.FindControl("CheckBoxSelector")); if (gvr.Cells[2].Text.ToString() == BillboardCodefromdb) { cb.Checked = true; billboardDisplayTB.Text = billboardDisplayTB.Text + "," + gvr.Cells[2].Text; } } } // CompareValidator1.ValueToCompare = DateTime.Now.ToShortDateString(); } billboardDisplayTB.Text = (billboardDisplayTB.Text).Substring(1); SqlCommand cmdCat = new SqlCommand("select * from [AdvertisementCategory] where AdvID=@ID", conn); SqlParameter paramCat = new SqlParameter(); paramCat.ParameterName = "@ID"; paramCat.Value = Session["AdvertID"].ToString(); cmdCat.Parameters.Add(paramCat); SqlDataAdapter sdaCat = new SqlDataAdapter(); DataTable datatableCat = new DataTable(); cmdCat.Connection = conn; sdaCat.SelectCommand = cmdCat; sdaCat.Fill(datatableCat); string name = ""; for (int i = 0; i < datatableCat.Rows.Count; i++) { //Auto,Bus,Career,Fin,Food,Gov,Health,Home,Ins,Int,Law,Mobile,Mother,Pets,Photo,Polit, //Rec,Rest,Retail,Shop,Sport,Style,Tech,Tel,Travel,Wed,Women //int ageChecker = Convert.ToInt32(datatable.Rows[i]["AgeID"]); string catChecker = ((String)datatableCat.Rows[i]["CategoryID"]); for (int x = 0; x < CheckBoxList1.Items.Count; x++) { if (catChecker == CheckBoxList1.Items[x].Value) { CheckBoxList1.Items[x].Selected = true; name = name + "," + CheckBoxList1.Items[x].Value; break; } } // adCategoryTB.Text = (name).Substring(1); } adCategoryTB.Text = name.Substring(1); } }