예제 #1
0
        protected void Save(object sender, EventArgs e)
        {
            try
            {
                if (txtHotelName.Text == null)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "alert('Fill Hotel Name')", true);
                }
                else if (txtEmailID.Text == null)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "alert('Fill Email ID')", true);
                }
                else if (txtGSTIN.Text == null)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "alert('Fill GSTIN No')", true);
                }
                else
                {
                    con.Open();
                    SqlTransaction trans = con.BeginTransaction(IsolationLevel.ReadCommitted);

                    string qry = "";
                    qry = "select  MAX(HOTELID) as HOTELID  from SPCN_HOTEL_MASTER ";
                    SqlCommand cmd = new SqlCommand();
                    cmd             = new SqlCommand(qry, con);
                    cmd.Transaction = trans;
                    cmd.Clone();
                    SqlDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        objML_Masters.ID = dr["HOTELID"].ToString();
                    }
                    if (clsCommon.myLen(objML_Masters.ID) <= 0)
                    {
                        objML_Masters.ID = "HOTEL0000001";
                    }
                    else
                    {
                        objML_Masters.ID = clsCommon.incval(objML_Masters.ID);
                    }
                    con.Close();
                    objML_Masters.Name        = txtHotelName.Text != "" ? txtHotelName.Text : null;
                    objML_Masters.PublishDate = txtHotelCreatedDate.Text != "" ? txtHotelCreatedDate.Text : null;
                    objML_Masters.Address     = txtAddress.Text != "" ? txtAddress.Text : null;
                    objML_Masters.State       = ddlState.SelectedValue != "" ? ddlState.SelectedValue : null;
                    objML_Masters.City        = ddlcity.SelectedValue != "" ? ddlcity.SelectedValue : null;
                    objML_Masters.Country     = ddlCountry.SelectedValue != "" ? ddlCountry.SelectedValue : null;
                    objML_Masters.ZipCode     = txtZip.Text != "" ? txtZip.Text : null;
                    objML_Masters.Website     = txtWebSite.Text != "" ? txtWebSite.Text : null;
                    objML_Masters.EmailID     = txtEmailID.Text != "" ? txtEmailID.Text : null;
                    objML_Masters.Phone1      = txtPhone1.Text != "" ? txtPhone1.Text : null;
                    objML_Masters.Phone2      = txtPhone2.Text != "" ? txtPhone2.Text : null;
                    objML_Masters.MobileNo    = txtMobile.Text != "" ? txtMobile.Text : null;
                    objML_Masters.PanNo       = txtPanNo.Text != "" ? txtPanNo.Text : null;
                    objML_Masters.TanNo       = txtTanNo.Text != "" ? txtTanNo.Text : null;
                    objML_Masters.GSTIN       = txtGSTIN.Text != "" ? txtGSTIN.Text : null;
                    objML_Masters.CreatedBy   = Session["UserName"].ToString();
                    objML_Masters.ModifyBy    = Session["UserName"].ToString();
                    int x = objBL_Masters.BL_SaveHotelMaster(objML_Masters);
                    if (x == 1)
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "alert('Data Saved !')", true);
                    }
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "alert('" + ex.Message.ToString() + "')", true);
            }
        }