Ejemplo n.º 1
0
        private void DoBind()
        {
            List <SiteInspectionCompleteMaster> lst = SiteInspectionManager.GetAll();

            if (lst.Count > 0)
            {
                lvData.DataSource = lst;
                lvData.DataBind();
                dvData.Visible   = true;
                PagerRow.Visible = true;
            }
            else
            {
                dvData.Visible   = false;
                PagerRow.Visible = false;
            }
        }
Ejemplo n.º 2
0
 protected void lvData_ItemCommand(object sender, ListViewCommandEventArgs e)
 {
     lblError.Text      = string.Empty;
     lblSave.Text       = string.Empty;
     lblMessage.Text    = string.Empty;
     lblMessage.Visible = false;
     lblError.Visible   = false;
     lblSave.Visible    = false;
     if (e.CommandName.Equals("DoEdit"))
     {
         int id = Convert.ToInt32(e.CommandArgument);
         hdId.Value = id.ToString();
         Label lblName = (Label)e.Item.FindControl("lblName");
         txtName.Text = lblName.Text;
     }
     else if (e.CommandName.Equals("DoDelete"))
     {
         // In Case of delete
         try
         {
             var list = CheckPrimaryValue.CheckPrimaryValueExists(0, 0, 0, 0, 0, 0, 0, 0, Convert.ToInt32(e.CommandArgument), 0, 0, 0, 0, 0, 0, 0, 0);
             if (list.ToList().Count > 0)
             {
                 lblMessage.Text    = "Site Inspection is used so you can't delete !!!";
                 lblMessage.Visible = true;
                 return;
             }
             var siteInspection = SiteInspectionManager.GetById(Convert.ToInt32(e.CommandArgument));
             siteInspection.Status = false;
             SiteInspectionManager.Save(siteInspection);
             btnCancel_Click(null, null);
             lblSave.Text    = "Record Deleted Sucessfully.";
             lblSave.Visible = true;
         }
         catch (Exception ex)
         {
             lblError.Text    = "Record Not Deleted.";
             lblError.Visible = true;
         }
     }
 }
Ejemplo n.º 3
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     lblError.Text      = string.Empty;
     lblError.Visible   = false;
     lblSave.Text       = string.Empty;
     lblSave.Visible    = false;
     lblMessage.Visible = false;
     lblMessage.Text    = string.Empty;
     try
     {
         using (TransactionScope scope = new TransactionScope())
         {
             bool exists = SiteInspectionManager.IsExist(txtName.Text.Trim(), Convert.ToInt32(hdId.Value));
             if (exists)
             {
                 lblMessage.Text    = "Site Inspection Complete already exists.";
                 lblMessage.Visible = true;
                 txtName.Focus();
                 return;
             }
             SiteInspectionCompleteMaster siteInspection = SiteInspectionManager.GetById(Convert.ToInt32(hdId.Value));
             siteInspection.SiteInspectionCompleteName = txtName.Text;
             siteInspection.Status = true;
             SiteInspectionManager.Save(siteInspection);
             saveMsg = hdId.Value == "0" ? "Record Saved Sucessfully." : "Record Updated Sucessfully.";
             btnCancel_Click(null, null);
             lblSave.Text    = saveMsg;
             lblSave.Visible = true;
             scope.Complete();
         }
     }
     catch (Exception ex)
     {
         lblError.Visible = true;
         lblError.Text    = "Record Not Saved !!!";
     }
 }