Ejemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (helper.ExecutePlainQuery("select * from tbl_Hostelinformation where [HostelName]='" + txtHostelName.Text + "' and BranchID=" + Session["BranchID"]).Rows.Count > 0 && String.IsNullOrEmpty(hfHostelID.Value))
                {
                    lblmsg.Text = helper.DisplayNotificationMessage(msgDiv, txtHostelName.Text + " already exists!", "alert alert-danger alert-icon alert-dismissible", icon, "icon mdi mdi-check");
                }
                else
                {
                    string msg = "Hostel detail has been added!";

                    TblHostelinformation obj = new TblHostelinformation();
                    obj.IsNew = true;

                    if (hfHostelID.Value != "")
                    {
                        obj.IsNew = false;
                        obj       = new TblHostelinformation(hfHostelID.Value);
                        msg       = "Hostel detail has been updated!";
                    }

                    obj.HostelName     = txtHostelName.Text;
                    obj.HostelContact  = txtHostelContact.Text;
                    obj.HostelFee      = Convert.ToInt32(txtHostelFee.Text);
                    obj.HostelLocation = txtHostelLocation.Text;
                    obj.BranchID       = Convert.ToInt32(Session["BranchID"]);
                    obj.EmployeeID     = Convert.ToInt32(ddlEmployees.SelectedValue);
                    obj.IsActive       = Convert.ToInt32(ddlStatus.SelectedValue);

                    obj.Save();
                    lblmsg.Text = helper.DisplayNotificationMessage(msgDiv, msg, "alert alert-success alert-icon alert-dismissible", icon, "icon mdi mdi-check");
                    helper.ClearInputs(Page.Controls);
                    hfHostelID.Value = "";
                }
            }
            catch (Exception ex)
            {
                lblmsg.Text = helper.DisplayNotificationMessage(msgDiv, ex.InnerException.ToString(), "alert alert-danger alert-icon alert-dismissible", icon, "icon mdi mdi-close-circle-o");
            }
        }
Ejemplo n.º 2
0
        private void cloneData()
        {
            if (Session["HostelID"] != null)
            {
                TblHostelinformation obj = new TblHostelinformation(Session["HostelID"]);
                txtHostelName.Text      = obj.HostelName;
                txtHostelContact.Text   = obj.HostelContact;
                txtHostelFee.Text       = obj.HostelFee.ToString();
                txtHostelLocation.Text  = obj.HostelLocation;
                ddlStatus.SelectedValue = obj.IsActive.ToString();
                LoadDesignation();
                TblEmployee objemp = new TblEmployee(obj.EmployeeID);
                ddlDesignation.SelectedValue = objemp.DesignationID.ToString();
                BindEmployees(ddlDesignation.SelectedValue);
                ddlEmployees.SelectedValue = obj.EmployeeID.ToString();

                hfHostelID.Value    = obj.HostelID.ToString();
                Session["HostelID"] = null;
            }
            else
            {
                hfHostelID.Value = "";
            }
        }