Ejemplo n.º 1
0
    protected void btnAddFlatSubmit_Click(object sender, EventArgs e)
    {
        DataAccess daAccess = new DataAccess();

        Flat newFlat = new Flat();

        newFlat.Block      = txtblock.Text;
        newFlat.Floor      = txtfloor.Text;
        newFlat.Intercom   = Convert.ToInt32(txtintercom.Text);
        newFlat.FlatNumber = txtflatno.Text;
        newFlat.FlatArea   = txtfltarea.Text;
        newFlat.BHK        = Convert.ToInt32(drpbhk.SelectedItem.Value);

        DateTime ActiveDate = Utility.GetCurrentDateTimeinUTC();

        string  query = "select * from dbo.Flats where FlatNumber='" + newFlat.FlatNumber + "' and SocietyID=" + SessionVariables.SocietyID;
        DataSet ds    = daAccess.ReadUserData(query);

        if (ds != null && ds.Tables[0].Rows.Count > 0)
        {
            ExistingUser = true;
        }
        else
        {
            ExistingUser = false;
        }
        try
        {
            if (ExistingUser == false)
            {
                int res = newFlat.AddFlat(newFlat);
                // SendMail(newUser.EmailID, newUser.Password, newUser.EmailID, newUser.FirstName);
                if (res > 0)
                {
                    lblassignHeading.Text = "success";
                }
                FillFlatdata();
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:HideAddFlat()", true);
            }
            else
            {
                //newFlat.AddFlat(ExistingUserID);
                //SendMail(newUser.EmailID, newUser.Password, newUser.EmailID, newUser.FirstName);
                //AddBillToFlat(newFlat.FlatNumber, newFlat.FlatArea);
                //GenerateInitialZeroBill(newFlat.FlatNumber, newFlat.FlatArea);
                //FillFlatdata();
                //ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:HideAddFlatModal()", true);
                lblAddFlatMessage.ForeColor = System.Drawing.Color.Red;
                lblAddFlatMessage.Text      = "Could not Submit Flat try later or Contact Admin";
            }
        }
        catch (Exception ex)
        {
            Utility.log("Addflat:btnAddflatSubmit_Click Exception" + ex.Message);
            lblAddFlatMessage.ForeColor = System.Drawing.Color.Red;
            lblAddFlatMessage.Text      = "Could not Submit  Flat try later or Contact Admin";
        }
    }