Esempio n. 1
0
        private void btnModify_Click(object sender, EventArgs e)
        {
            if (dgvMain.SelectedRows.Count != 0)
            {
                DataRowView row = (DataRowView)dgvMain.SelectedRows[0].DataBoundItem;

                UnitClassDialog classDialog = new UnitClassDialog(row["UNITCLASSCODE"].ToString(),
                                                                row["UNITCLASSNAME"].ToString(),
                                                                row["MEMO"].ToString());

                if (classDialog.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        UnitDal unitDal = new UnitDal();
                        unitDal.SaveUnitClass(classDialog.ClassCode,
                                        classDialog.ClassName,
                                        classDialog.Memo);
                        bsMain.DataSource = unitDal.GetUnitClass();
                    }
                    catch (Exception exp)
                    {
                        THOKUtil.ShowInfo(exp.Message);
                    }
                }
            }
        }
Esempio n. 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtCode.Text.Trim().Length == 0)
                {
                    THOKUtil.ShowInfo("������λ���벻��Ϊ�գ����������롣");
                    txtCode.Focus();
                    return;
                }

                if (txtName.Text.Trim().Length == 0)
                {
                    THOKUtil.ShowInfo("������λ���Ʋ���Ϊ�գ����������롣");
                    txtName.Focus();
                    return;
                }

                if (isAdd)
                {

                    DataRow newRow = unitTable.NewRow();
                    newRow["UNITCODE"] = txtCode.Text;
                    newRow["UNITNAME"] = txtName.Text;
                    newRow["UNITCLASS"] = code;
                    newRow["UNITCLASSNAME"] = txtClass.Text;
                    newRow["MEMO"] = txtMemo.Text;

                    UnitDal unitDal = new UnitDal();
                    unitDal.AddUnit(newRow);

                    TreeNode node = new TreeNode();
                    node.Name = txtCode.Text;
                    node.Text = string.Format("{0}[{1}]", txtName.Text, txtCode.Text.Trim());
                    node.Tag = newRow;
                    tvLeft.SelectedNode.Nodes.Add(node);
                    tvLeft.SelectedNode = node;
                    isAdd = false;
                }
                else
                {
                    DataRow row = (DataRow)tvLeft.SelectedNode.Tag;
                    row["UNITNAME"] = txtName.Text;
                    row["MEMO"] = txtMemo.Text;

                    UnitDal unitDal = new UnitDal();
                    unitDal.SaveUnit(row);

                    tvLeft.SelectedNode.Text = string.Format("{0}[{1}]", txtName.Text, txtCode.Text.Trim());
                    tvLeft.Tag = row;
                }
            }
            catch (Exception exp)
            {
                THOKUtil.ShowInfo(exp.Message);
            }
        }
Esempio n. 3
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (tvLeft.SelectedNode != null && tvLeft.SelectedNode.Level == 1)
     {
         try
         {
             UnitDal unitDal = new UnitDal();
             unitDal.DeleteUnit(tvLeft.SelectedNode.Name);
             tvLeft.SelectedNode.Remove();
         }
         catch (Exception exp)
         {
             THOKUtil.ShowInfo("ɾ��������λʧ�ܣ�ԭ��" + exp.Message);
         }
     }
 }
Esempio n. 4
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (dgvMain.SelectedRows.Count != 0)
     {
         DataGridViewRow row = dgvMain.SelectedRows[0];
         try
         {
             UnitDal unitDal = new UnitDal();
             unitDal.DeleteUnitClass(row.Cells[0].Value.ToString());
             bsMain.DataSource = unitDal.GetUnitClass();
         }
         catch (Exception exp)
         {
             THOKUtil.ShowInfo(exp.Message);
         }
     }
 }
Esempio n. 5
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     UnitClassDialog classDialog = new UnitClassDialog();
     if (classDialog.ShowDialog() == DialogResult.OK)
     {
         try
         {
             UnitDal unitDal = new UnitDal();
             unitDal.AddUnitClass(classDialog.ClassCode,
                             classDialog.ClassName,
                             classDialog.Memo);
             bsMain.DataSource = unitDal.GetUnitClass();
         }
         catch (Exception exp)
         {
             THOKUtil.ShowInfo(exp.Message);
         }
     }
 }
Esempio n. 6
0
        private void InitializeUnit()
        {
            UnitDal unitDal = new UnitDal();
            DataTable classTable = unitDal.GetUnitClass();
            DataTable unitTable = unitDal.GetUnit();

            foreach (DataRow classRow in classTable.Rows)
            {
                TreeNode classNode = new TreeNode();
                classNode.Name = classRow["UNITCLASSCODE"].ToString();
                classNode.Text = string.Format("{0}[{1}]", classRow["UNITCLASSNAME"], classRow["UNITCLASSCODE"]);
                classNode.Tag = classRow["UNITCLASSNAME"];

                DataRow[] unitRows = unitTable.Select(string.Format("UNITCLASS='{0}'", classRow["UNITCLASSCODE"]));
                foreach (DataRow unitRow in unitRows)
                {
                    TreeNode unitNode = new TreeNode();
                    unitNode.Name = unitRow["UNITCODE"].ToString();
                    unitNode.Text = string.Format("{0}[{1}]", unitRow["UNITNAME"], unitRow["UNITCODE"].ToString().Trim());
                    unitNode.Tag = unitRow["UNITNAME"];
                    classNode.Nodes.Add(unitNode);
                }

                tvUnit.Nodes.Add(classNode);
            }
        }
Esempio n. 7
0
        private void pnlMain_ParentChanged(object sender, EventArgs e)
        {
            if (!hasInitialize)
            {
                UnitDal unitDal = new UnitDal();
                DataTable classTable = unitDal.GetUnitClass();
                unitTable = unitDal.GetUnit();

                foreach (DataRow classRow in classTable.Rows)
                {
                    TreeNode classNode = new TreeNode();
                    classNode.Name = classRow["UNITCLASSCODE"].ToString();
                    classNode.Text = string.Format("{0}[{1}]", classRow["UNITCLASSNAME"], classRow["UNITCLASSCODE"]);
                    classNode.Tag = classRow["UNITCLASSNAME"];

                    DataRow[] unitRows = unitTable.Select(string.Format("UNITCLASS='{0}'", classRow["UNITCLASSCODE"]));
                    foreach (DataRow unitRow in unitRows)
                    {
                        TreeNode unitNode = new TreeNode();
                        unitNode.Name = unitRow["UNITCODE"].ToString();
                        unitNode.Text = string.Format("{0}[{1}]", unitRow["UNITNAME"], unitRow["UNITCODE"].ToString().Trim());
                        unitNode.Tag = unitRow;
                        classNode.Nodes.Add(unitNode);
                    }

                    tvLeft.Nodes.Add(classNode);
                }
                hasInitialize = true;
                tvLeft.ExpandAll();
                tvLeft.Focus();
            }
        }
Esempio n. 8
0
 private void pnlMain_ParentChanged(object sender, EventArgs e)
 {
     UnitDal unitDal = new UnitDal();
     bsMain.DataSource = unitDal.GetUnitClass();
 }