Ejemplo n.º 1
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;

            Page.Validate("TypeofDamage");
            if (!Page.IsValid)
            {
                return;
            }

            try {
                bool exists = TypeofDamageManager.IsExist(txtTypeofDamage.Text.Trim(), Convert.ToInt32(hdId.Value));
                if (exists)
                {
                    lblMessage.Text    = "Type Of Damage already exists.";
                    lblMessage.Visible = true;
                    txtTypeofDamage.Focus();
                    return;
                }
                TypeOfDamageMaster obj = TypeofDamageManager.GetbyTypeOfDamageId(Convert.ToInt32(hdId.Value));
                obj.TypeOfDamage = txtTypeofDamage.Text;

                if (!string.IsNullOrEmpty(txtSort.Text))
                {
                    obj.Sort = (byte)Convert.ToInt32(txtSort.Text);
                }

                obj.Status = true;

                if (clientID > 0)
                {
                    obj.ClientId = clientID;
                }

                TypeofDamageManager.Save(obj);
                saveMsg = hdId.Value == "0" ? "Record Saved Successfully." : "Record Updated Successfully.";
                btnCancel_Click(null, null);
                lblSave.Text    = saveMsg;
                lblSave.Visible = true;
            }
            catch (Exception ex) {
                lblError.Visible = true;
                lblError.Text    = "Record Not Saved !!!";
            }
        }
Ejemplo n.º 2
0
        protected void cbxHidden_CheckedChanged(object sender, EventArgs e)
        {
            ListViewItem lvItem         = ((CheckBox)sender).NamingContainer as ListViewItem;
            int          idx            = lvItem.DataItemIndex;
            int          TypeofDamageId = (int)lvData.DataKeys[idx].Value;

            TypeOfDamageMaster damageType = TypeofDamageManager.GetbyTypeOfDamageId(TypeofDamageId);

            if (damageType != null)
            {
                damageType.IsHidden = ((CheckBox)sender).Checked;

                TypeofDamageManager.Save(damageType);
                DoBind();
            }
        }
Ejemplo n.º 3
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 lblTypeOfDamage = (Label)e.Item.FindControl("lblTypeOfDamage");
                txtTypeofDamage.Text = lblTypeOfDamage.Text;

                Label lblSort = (Label)e.Item.FindControl("lblSort");
                txtSort.Text = lblSort.Text;
            }
            else if (e.CommandName.Equals("DoDelete"))
            {
                // In Case of delete
                try {
                    //Label lblTypeOfDamage = (Label)e.Item.FindControl("lblTypeOfDamage");
                    //var list = CheckPrimaryValue.checkTypeofDamage(lblTypeOfDamage.Text);
                    //if (list.ToList().Count > 0) {
                    //	lblMessage.Text = "Type of Damage is used so you can't delete !!!";
                    //	lblMessage.Visible = true;
                    //	return;
                    //}

                    var dt = TypeofDamageManager.GetbyTypeOfDamageId(Convert.ToInt32(e.CommandArgument));

                    dt.Status = false;

                    TypeofDamageManager.Save(dt);
                    DoBind();

                    lblSave.Text    = "Record Deleted Successfully.";
                    lblSave.Visible = true;
                }
                catch (Exception ex) {
                    lblError.Text    = "Record Not Deleted.";
                    lblError.Visible = true;
                }
            }
        }