Ejemplo n.º 1
0
        private void SearchItem()
        {
            EquipmentTypeEN en = new EquipmentTypeEN();

            en = ClassEuipt.SearchByID(Convert.ToInt32(hidID.Value));
            this.SelectedItem = en;
            hidParentID.Value = en.ParentID.ToString();
        }
Ejemplo n.º 2
0
        private void SetData()
        {
            EquipmentTypeEN en = new EquipmentTypeEN();

            en.ID        = Convert.ToInt32(hidID.Value);
            en.TypeName  = txtTypeName.Text;
            en.ParentID  = Convert.ToInt32(hidParentID.Value);
            SelectedItem = en;
        }
Ejemplo n.º 3
0
        public static ResultEN Delete_Type(EquipmentTypeEN en)
        {
            ResultEN   res    = new ResultEN();
            SqlCommand sqlCmd = new SqlCommand();

            sqlCmd.CommandText = "Delete From " + tb_name_type + " WHERE ParentID = " + en.ID;
            sqlCmd.CommandType = CommandType.Text;

            // delete child
            res.result = ClassMain.ExecuteComand(sqlCmd);


            // delete parent
            sqlCmd.CommandText = "Delete From " + tb_name_type + " WHERE ID = " + en.ID;
            res.result         = ClassMain.ExecuteComand(sqlCmd);

            return(res);
        }
Ejemplo n.º 4
0
        public static ResultEN Insert_Type(EquipmentTypeEN en)
        {
            // SqlCommand sqlCmd = new SqlCommand();
            // sqlCmd.CommandText = "insert into " + tb_name_type +" ()";


            List <ClassFieldValue> fields = new List <ClassFieldValue>();

            fields.Add(new ClassFieldValue("TypeName", en.TypeName));
            fields.Add(new ClassFieldValue("ParentID", en.ParentID));
            fields.Add(new ClassFieldValue("CreatedBy", HttpContext.Current.User.Identity.Name));
            fields.Add(new ClassFieldValue("CreatedDate", DateTime.Now));
            ResultEN res = new ResultEN();

            // ClassMain cls = new ClassMain();
            res = ClassMain.Insert(tb_name_type, fields);


            return(res);
        }
Ejemplo n.º 5
0
        public static EquipmentTypeEN SearchByID(int ID)
        {
            SqlCommand sqlCmd = new SqlCommand();

            sqlCmd.CommandText = "select * from " + tb_name_type + " Where ID =" + ID.ToString();

            DataTable       dt = ClassMain.ExecuteComandTable(sqlCmd);
            EquipmentTypeEN en = new EquipmentTypeEN();

            if (dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];
                en.ID       = Convert.ToInt32(dr["ID"]);
                en.TypeName = Convert.ToString(dr["TypeName"]);
                en.ParentID = Convert.ToInt32(dr["ParentID"]);
                return(en);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ResultEN res = new ResultEN();

            if (mode == "add")
            {
                EquipmentTypeEN en = new EquipmentTypeEN();
                if (Level == 0)
                {
                    en.TypeName = txtTypeName.Text;
                }
                else
                {
                    en.TypeName = txtSubName.Text;
                }

                en.ParentID = Convert.ToInt32(hidParentID.Value);

                res = ClassEuipt.Insert_Type(en);
            }
            else
            {
                SetData();
                EquipmentTypeEN en = new EquipmentTypeEN();
                en  = SelectedItem;
                res = ClassEuipt.Update_Type(en);
            }

            if (res.result)
            {
                MessageShow("บันทึกเรียบร้อยแล้ว");
                BindGrid();
                BindTree();
                SetDefaultControl();
                this.SelectedItem = null;
            }
        }