public static bool CompareTT(SP s1, SP s2) { if (!s1.TrangThai && s2.TrangThai) { return(true); } return(false); }
public bool setSP(SP s) { List <SP> list = cloneDSSP(); list.Add(s); syncDSSP(list); return(true); }
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; }
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; }
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); }
public static bool CompareIDMH(SP s1, SP s2) { if (string.Compare(s1.ID_MH, s2.ID_MH) > 0) { return(true); } else { return(false); } }
public static bool CompareNSX(SP s1, SP s2) { if (string.Compare(s1.NSX.ToString(), s2.NSX.ToString()) > 0) { return(true); } else { return(false); } }
public static bool CompareIDSP(SP s1, SP s2) { if (s1.ID_SP >= s2.ID_SP) { return(true); } else { return(false); } }
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); }
public static bool CompareTen(SP s1, SP s2) { if (string.Compare(s1.Ten, s2.Ten) > 0) { return(true); } else { return(false); } }
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); }
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; } } } }
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); }
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); }
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); }
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); }
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; }
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; } } }