Example #1
0
    public void CountryInsertUpdate()
    {
        countryBLLObj.countryName = Convert.ToString(txtCountryName.Text);
        string id = Convert.ToString(Session["MarketingUser"]);

        if (Convert.ToString(ViewState["countryId"]) == "")
        {
            status = countryBLLObj.BLLCountryInsert(countryBLLObj);

            if (status == 1)
            {
                Response.Write("<script>alert('Country  Added')</script>");
                string maxcntid = "select max(countryId) from CountryMaster";
                string id1c     = cc.ExecuteScalar(maxcntid);
                string dateins  = DateTime.UtcNow.Date.ToShortDateString();// System.DateTime.Now.Date.ToString();
                dateins = cc.ChangeDate(dateins);
                string insert = "update CountryMaster set insdate='" + dateins + "',userId='" + id + "' where countryId=" + id1c.ToString() + "";

                cc.ExecuteNonQuery(insert);
            }
            else if (status == 0)
            {
                Response.Write("<script>alert('Country Not added')</script>");
            }
        }

        else
        {
            countryBLLObj.countryId = Convert.ToInt32(Convert.ToString(ViewState["countryId"]));
            status = countryBLLObj.BLLCountryUpdate(countryBLLObj);

            if (status > 0)
            {
                Response.Write("<script>alert('Country Updated')</script>");

                string cntid   = Convert.ToString(ViewState["countryId"]);
                string dateupd = DateTime.UtcNow.Date.ToShortDateString();


                dateupd = cc.ChangeDate(dateupd);
                string update = "update CountryMaster set modydate='" + dateupd + "',userId='" + id + "' where countryId=" + cntid.ToString() + "";

                cc.ExecuteNonQuery(update);
            }
            else
            {
                Response.Write("<script>alertalert('Country Exist')</script>");
            }
        }
    }