Example #1
0
 public static bool CompareTT(SP s1, SP s2)
 {
     if (!s1.TrangThai && s2.TrangThai)
     {
         return(true);
     }
     return(false);
 }
Example #2
0
        public bool setSP(SP s)
        {
            List <SP> list = cloneDSSP();

            list.Add(s);
            syncDSSP(list);
            return(true);
        }
Example #3
0
        public void AddSP()
        {
            if (tb_IDSP.Text == "")
            {
                MessageBox.Show("Nhập id sản phẩm!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                status = false;
                return;
            }
            foreach (SP i in CSDL_OOP.Instance.getAllSP())
            {
                if (tb_IDSP.Text == i.ID_SP.ToString())
                {
                    MessageBox.Show("ID sản phẩm đã tồn tại", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    status = false;
                    return;
                }
            }
            if (rbtn_Con.Checked == false && rbtn_Het.Checked == false)
            {
                MessageBox.Show("Chọn trạng thái!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                status = false;
                return;
            }
            if (cbb_MH.SelectedIndex == -1)
            {
                MessageBox.Show("Chọn loại mặt hàng!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                status = false;
                return;
            }
            string id = tb_IDSP.Text;

            for (int i = 0; i < id.Length; i++)
            {
                if (id[i] < '0' || id[i] > '9')
                {
                    MessageBox.Show("Id sản phẩm không chứa kí tự", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    status = false;
                    return;
                }
            }
            SP s = new SP();

            s.ID_SP = Convert.ToInt32(tb_IDSP.Text);
            s.Ten   = tb_Ten.Text;
            if (rbtn_Con.Checked == true)
            {
                s.TrangThai = true;
            }
            else
            {
                s.TrangThai = false;
            }
            s.NSX   = dateTimePicker1.Value;
            s.ID_MH = ((CBBItem)cbb_MH.SelectedItem).Value;
            CSDL_OOP.Instance.AddSPToCSDL(s);
            status = true;
        }
Example #4
0
 public void EditSPInCSDL(SP s, int index)
 {
     object[] o = new object[CSDL.Instance.DSSP.Columns.Count];
     o[0] = s.ID_SP;
     o[1] = s.Ten;
     o[2] = s.TrangThai;
     o[3] = s.NSX;
     o[4] = s.ID_MH;
     CSDL.Instance.DSSP.Rows[index].ItemArray = o;
 }
Example #5
0
 public void AddSPToCSDL(SP s)
 {
     object[] o = new object[CSDL.Instance.DSSP.Columns.Count];
     o[0] = s.ID_SP;
     o[1] = s.Ten;
     o[2] = s.TrangThai;
     o[3] = s.NSX;
     o[4] = s.ID_MH;
     CSDL.Instance.DSSP.Rows.Add(o);
 }
Example #6
0
 public static bool CompareIDMH(SP s1, SP s2)
 {
     if (string.Compare(s1.ID_MH, s2.ID_MH) > 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #7
0
 public static bool CompareNSX(SP s1, SP s2)
 {
     if (string.Compare(s1.NSX.ToString(), s2.NSX.ToString()) > 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #8
0
 public static bool CompareIDSP(SP s1, SP s2)
 {
     if (s1.ID_SP >= s2.ID_SP)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #9
0
        private SP get1SP(DataRow dr)
        {
            SP s = new SP();

            s.ID_SP     = Convert.ToInt32(dr["ID_SP"]);
            s.Ten       = dr["Ten"].ToString();
            s.TrangThai = Convert.ToBoolean(dr["TrangThai"]);
            s.NSX       = Convert.ToDateTime(dr["NSX"]);
            s.ID_MH     = dr["ID_MH"].ToString();
            return(s);
        }
Example #10
0
 public static bool CompareTen(SP s1, SP s2)
 {
     if (string.Compare(s1.Ten, s2.Ten) > 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #11
0
        public SP getSPByID(int ID_SP)
        {
            SP        s    = new SP();
            List <SP> list = cloneDSSP();

            foreach (var i in list)
            {
                if (i.ID_SP == ID_SP)
                {
                    return(i);
                }
            }
            return(s);
        }
Example #12
0
 public void Sort(List <SP> list, Compare cmp)
 {
     for (int i = 0; i < list.Count; i++)
     {
         for (int j = i + 1; j < list.Count; j++)
         {
             if (cmp(list[i], list[j]))
             {
                 SP temp = list[i];
                 list[i] = list[j];
                 list[j] = temp;
             }
         }
     }
 }
Example #13
0
 private void setSP(SP s)
 {
     tb_IDSP.Text = s.ID_SP.ToString();
     tb_Ten.Text  = s.Ten;
     if (s.TrangThai)
     {
         rbtn_Con.Checked = true;
     }
     else
     {
         rbtn_Het.Checked = true;
     }
     dateTimePicker1.Value = s.NSX;
     cbb_MH.SelectedItem   = Convert.ToInt32(s.ID_MH);
 }
Example #14
0
        public bool setSPByID(int ID_SP, SP s)
        {
            List <SP> list  = cloneDSSP();
            int       index = 0;

            foreach (var i in list)
            {
                if (i.ID_SP == ID_SP)
                {
                    list[index] = s;
                    break;
                }
                index++;
            }
            syncDSSP(list);
            return(true);
        }
Example #15
0
        public List <SP> SortSPBy(string property)
        {
            Compare   cmp;
            List <SP> list = cloneDSSP();

            switch (property)
            {
            case "ID_SP":
                cmp = SP.CompareIDSP;
                break;

            case "Ten":
                cmp = SP.CompareTen;
                break;

            case "TrangThai":
                cmp = SP.CompareTT;
                break;

            case "NSX":
                cmp = SP.CompareNSX;
                break;

            case "ID_MH":
                cmp = SP.CompareIDMH;
                break;

            default:
                cmp = SP.CompareIDSP;
                break;
            }
            for (int i = 0; i < list.Count; i++)
            {
                for (int j = i + 1; j < list.Count; j++)
                {
                    if (cmp(list[i], list[j]))
                    {
                        SP temp = list[i];
                        list[i] = list[j];
                        list[j] = temp;
                    }
                }
            }
            return(list);
        }
Example #16
0
        private SP getSP()
        {
            SP s = new SP();

            s.ID_SP = Convert.ToInt32(tb_IDSP.Text);
            s.Ten   = tb_Ten.Text;
            if (rbtn_Con.Checked)
            {
                s.TrangThai = true;
            }
            else
            {
                s.TrangThai = false;
            }
            s.NSX   = dateTimePicker1.Value;
            s.ID_MH = ((CBBItem)cbb_MH.SelectedItem).Value;
            return(s);
        }
Example #17
0
        public void EditSP()
        {
            SP s = new SP();

            s.ID_SP = Convert.ToInt32(tb_IDSP.Text);
            s.Ten   = tb_Ten.Text;
            if (rbtn_Con.Checked == true)
            {
                s.TrangThai = true;
            }
            else
            {
                s.TrangThai = false;
            }
            s.NSX   = dateTimePicker1.Value;
            s.ID_MH = ((CBBItem)cbb_MH.SelectedItem).Value;
            CSDL_OOP.Instance.EditSPInCSDL(s, index);
            status = true;
        }
Example #18
0
        public void LoadDataToEdit()
        {
            SP s = CSDL_OOP.Instance.getAllSP()[index];

            tb_IDSP.Text = s.ID_SP.ToString();
            tb_Ten.Text  = s.Ten;
            if (s.TrangThai == true)
            {
                rbtn_Con.Checked = true;
            }
            else
            {
                rbtn_Het.Checked = true;
            }
            dateTimePicker1.Value = s.NSX;
            for (int i = 0; i < cbb_MH.Items.Count; i++)
            {
                if (s.ID_MH == ((CBBItem)cbb_MH.Items[i]).Value)
                {
                    cbb_MH.SelectedIndex = i;
                    break;
                }
            }
        }