protected void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         ObjUnit             = new clsUnits();
         ObjUnit.strUnitName = Convert.ToString(txtName.Text);
         ObjUnit.strUnitAbbr = Convert.ToString(txtAbbr.Text);
         ObjUnit.strDesc     = Convert.ToString(txtDesc.Text);
         int i = ObjUnit.InsertUnitMasterData();
         if (i == 1)
         {
             lblMsg.Text  = "Record inserted";
             txtAbbr.Text = "";
             txtDesc.Text = "";
             txtName.Text = "";
         }
         else
         {
             lblMsg.Text = "Record not inserted";
         }
     }
     catch (Exception ex)
     {
         lblMsg.Text = ex.Message;
     }
 }
 protected void btnShowAll_Click(object sender, EventArgs e)
 {
     try
     {
         if (btnShowAll.Text == "Show All")
         {
             ObjUnit = new clsUnits();
             DataSet ds = ObjUnit.GetAllUnitsData();
             if (ds.Tables[0].Rows.Count != 0)
             {
                 grdUnit.DataSource = ds.Tables[0];
                 grdUnit.DataBind();
             }
             else
             {
                 grdUnit.EmptyDataText = "No Records Found to display.";
                 grdUnit.DataBind();
             }
             divUnit.Visible = true;
             btnShowAll.Text = "Close";
         }
         else if (btnShowAll.Text == "Close")
         {
             divUnit.Visible = false;
             btnShowAll.Text = "Show All";
         }
     }
     catch (Exception ex)
     {
         lblMsg.Text = ex.Message;
     }
 }
Ejemplo n.º 3
0
 private void BindUnitsData()
 {
     try
     {
         clsUnits objUnit = new clsUnits();
         DataSet  ds      = objUnit.GetAllUnitsData();
         if (ds.Tables[0].Rows.Count != 0)
         {
             ddlUnitId.DataSource     = ds.Tables[0];
             ddlUnitId.DataTextField  = "UnitName";
             ddlUnitId.DataValueField = "UnitId";
             ddlUnitId.DataBind();
         }
         ddlUnitId.Items.Insert(0, "--Select One--");
     }
     catch (Exception)
     {
         lblMsg.Text = "Run Time Exception";
     }
 }