using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Data.SqlClient; public partial class UpdateHosting : System.Web.UI.Page { //SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["con"]); SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString); DataSet ds = new DataSet(); ShowHide objSH = new ShowHide(); FillDD objFillDD = new FillDD(); Validate objValidate = new Validate(); Extra objExtra = new Extra(); Dashboard ojbDash = new Dashboard(); DateTime HRegDate; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string domid = Request.QueryString["Id"]; lblWhr1.Text = domid; objFillDD.Get_DDList(ref DDDomainList, "Id", "DomainName", "tbl_DomainMaster", ref lblerr); objFillDD.Get_RecordsSelected(ref DDDomainList, domid, ref lblerr); Get_HostingRecords(); fill_DDRegBy(); fill_DGDetails(); } } void fill_DGDetails() { try { string view = "Select convert(varchar(11),h.HRegDate,101)as HRegDate,h.HPeriod,convert(varchar(11),h.HExpDate,101)as HExpDate,h.HRegisterBy,h.HFtpUrl,h.HUid,h.HPass,h.HSpace,h.HReNew,d.DomainName,h.EntryBy,convert(varchar(12),h.EntryDate,101) as EntryDate,h.ServerNm from tbl_HostingDetails h,tbl_DomainMaster d Where h.DomainName = d.Id and h.DomainName='" + lblWhr1.Text + "' order by h.Id Desc"; //string view = "Select Id,DomId,DomainName, convert(varchar(11),DRegDate,103)as DRegDate, convert(varchar(11),DExpDate,103)as DExpDate,convert(varchar(11),HRegDate,103)as HRegDate, convert(varchar(11),HExpDate,103)as HExpDate,HRegisterBy,HFtpUrl,HUid,HPass,HSpace,EntryBy,convert(varchar(10),EntryDate,103)as EntryDate,companyname from dbo.VW_DomainHosting Where DomId ='" + lblWhr1.Text + "' order by Id Desc"; SqlDataAdapter adp1 = new SqlDataAdapter(view, con); DataSet ds1 = new DataSet(); adp1.Fill(ds1, "DH1"); DGDetails.DataSource = ds1.Tables["DH1"]; DGDetails.DataBind(); } catch (Exception exp) { lblerr.Text = ("DG Alert! : " + exp.Message); } } void fill_DDRegBy() { objFillDD.Get_DDList(ref DDHRegby, "Id", "CompanyName", "tbl_RegisteredBy", ref lblerr); } bool CheckIfNumberic(string myNumber) { bool IsNum = true; for (int index = 0; index < myNumber.Length; index++) { if (!Char.IsNumber(myNumber[index])) { IsNum = false; break; } } return IsNum; } void Get_HostingRecords() { try { if ((con.State == ConnectionState.Open)) { con.Close(); } SqlCommand cmd = new SqlCommand("Select convert(varchar(11),HRegDate,101)as HRegDate,HPeriod,HRegisterBy,HFtpUrl,HUid,HPass,HSpace,HReNew from tbl_HostingDetails Where DomainName=" + lblWhr1.Text + "", con); SqlDataReader dr; con.Open(); dr = cmd.ExecuteReader(); if (dr.Read()) { string StrHRegDt, StrHExp, StrHRegby; StrHRegDt = dr["HRegDate"].ToString().Trim(); StrHExp = dr["HPeriod"].ToString().Trim(); StrHRegby = dr["HRegisterBy"].ToString().Trim(); txtHUrl.Text = dr["HFtpUrl"].ToString().Trim(); txtHUid.Text = dr["HUid"].ToString().Trim(); txtHPass.Text = dr["HPass"].ToString().Trim(); txtHspace.Text = dr["HSpace"].ToString().Trim(); lblHRenew.Text = dr["HReNew"].ToString().Trim(); if (StrHRegDt != "" && StrHExp != "0") { txtHRegdt.Text = StrHRegDt; lblHchk.Text = "Yes"; } else { lblHchk.Text = "No"; } objFillDD.Get_RecordsSelected(ref DDHExpdt, StrHExp, ref lblerr); objFillDD.Get_RecordsSelected(ref DDHRegby, StrHRegby, ref lblerr); } else { lblHchk.Text = "No"; } } catch (Exception ex) { lblerr.Text = "Error :" + ex.Message; } finally { con.Close(); } } protected void btnUpdate_Click(object sender, ImageClickEventArgs e) { try { if (DDDomainList.SelectedItem.Value == "0") { lblerr.Text = "Alert! : Select Domain Name"; } else if (tbl_HostD.Visible == true && txtHRegdt.Text == "") { lblerr.Text = "Alert! : Please Select Hosting Registration Date"; } else if (tbl_HostD.Visible == true && DDHExpdt.SelectedItem.Value == "0") { lblerr.Text = "Alert! : Please Select Hosting Expiry on"; } else if (tbl_HostD.Visible == true && DDHRegby.SelectedItem.Value == "0") { lblerr.Text = "Alert! : Please Select Hosting Registred by Company"; } else if (tbl_HostD.Visible == true && txtHUrl.Text == "") { lblerr.Text = "Alert! : Please Enter Hosting FTP Url"; } else if (tbl_HostD.Visible == true && txtHUid.Text == "") { lblerr.Text = "Alert! : Please Enter Hosting FTP User Id"; } else if (tbl_HostD.Visible == true && txtHPass.Text == "") { lblerr.Text = "Alert! : Please Enter Hosting FTP User Password"; } else if (tbl_HostD.Visible == true && !CheckIfNumberic(txtHspace.Text)) { lblerr.Text = "Alert! : Hosting space accepts only numeric values"; } else { if (txtHRegdt.Text != "") { HRegDate = Convert.ToDateTime(txtHRegdt.Text); HRegDate = HRegDate.AddYears(Convert.ToInt32(DDHExpdt.SelectedItem.Value)); lblHexp.Text = Convert.ToString(HRegDate); } if (con.State == ConnectionState.Closed) { con.Open(); } //string update = "update tbl_DomainHosting set DRegDate='" + txtDRegDt.Text + "', DPeriod='" + Convert.ToInt32(DDDExpdt.SelectedItem.Value) + "', DExpDate='" + lblDexp.Text + "', DRegisterBy='" + DDDRegby.SelectedItem.Value + "', EntryBy='" + Session["AdminAuth"] + "', EntryDate='" + DateTime.Today + "' where DomainName='" + DDDomainList.SelectedItem.Value + "'"; string update = "update tbl_HostingDetails set HRegDate='" + txtHRegdt.Text + "', HPeriod='" + Convert.ToInt32(DDHExpdt.SelectedItem.Value) + "', HExpDate='" + lblHexp.Text + "', HRegisterBy='" + DDHRegby.SelectedItem.Value + "', HFtpUrl='" + txtHUrl.Text + "', HUid='" + txtHUid.Text + "', HPass='" + txtHPass.Text + "', HSpace='" + txtHspace.Text + "' where DomainName='" + DDDomainList.SelectedItem.Value + "'"; SqlCommand cm3 = new SqlCommand(update, con); cm3.ExecuteNonQuery(); con.Close(); fill_DGDetails(); lblerr.Text = "Hosting details Updated Successfully"; } } catch (Exception ex) { lblerr.Text = "Update Alert! : " + ex.Message; } } }