Exemplo n.º 1
0
    protected void btnCSave_Click(object sender, EventArgs e)
    {
        if (txtClassName.Text == "" || txtClassName.Text == null)
        {
            DisplayMessage("Enter Class Name");
            System.Web.UI.ScriptManager.GetCurrent(this).SetFocus(txtClassName);
            return;
        }
        int b = 0;

        if (editid.Value != "")
        {
            DataTable dtCate = objDesg.GetClassMaster(Session["CompId"].ToString().ToString());
            dtCate = new DataView(dtCate, "Class='" + txtClassName.Text + "'", "", DataViewRowState.CurrentRows).ToTable();
            if (dtCate.Rows.Count > 0)
            {
                if (dtCate.Rows[0]["Class_ID"].ToString() != editid.Value)
                {
                    txtClassName.Text = "";
                    DisplayMessage("Class Already Exists");
                    System.Web.UI.ScriptManager.GetCurrent(this).SetFocus(txtClassName);
                    return;
                }
            }


            b            = objDesg.UpdateClassMaster(Session["CompId"].ToString().ToString(), editid.Value, txtClassName.Text, txtClassNameL.Text.Trim().ToString(), "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), "True", Session["UserId"].ToString(), DateTime.Now.ToString());
            editid.Value = "";
            if (b != 0)
            {
                Reset();
                FillGrid();
                DisplayMessage("Record Updated");
            }
            else
            {
                DisplayMessage("Record  Not Updated");
            }
        }
        else
        {
            DataTable dtPro = objDesg.GetClassMaster(Session["CompId"].ToString().ToString());
            dtPro = new DataView(dtPro, "Class='" + txtClassName.Text + "'", "", DataViewRowState.CurrentRows).ToTable();

            if (dtPro.Rows.Count > 0)
            {
                txtClassName.Text = "";
                DisplayMessage("Class Name Already Exists");
                System.Web.UI.ScriptManager.GetCurrent(this).SetFocus(txtClassName);
                return;
            }

            b = objDesg.InsertClassMaster(Session["CompId"].ToString().ToString(), txtClassName.Text, txtClassNameL.Text.Trim(), "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), "True", Session["UserId"].ToString(), DateTime.Now.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString());
            if (b != 0)
            {
                DisplayMessage("Record Saved");
                Reset();
                FillGrid();
            }
            else
            {
                DisplayMessage("Record  Not Saved");
            }
        }
    }