private void ButtonThemVaoDanhSach_Click(object sender, EventArgs e) { Medicine medicine; BoolClass boolClass = new BoolClass() { isChanged = false }; ThemSanPhamForm themSanPhamForm = new ThemSanPhamForm(boolClass); themSanPhamForm.ShowDialog(); if (boolClass.isChanged == true) { ListShow.Items.Clear(); List <Medicine> medicines = MedicineHelper.GetMedicines(); int i = 0; foreach (var item in medicines) { ListViewItem listViewItem = new ListViewItem(new string[] { i.ToString(), item.ID_Medicine.ToString(), item.Name_Medicine, item.Remain_Amount.ToString(), item.Expiry_Date.ToString() }); ListShow.Items.Add(listViewItem); i++; } } ShowMedicines.InitComboBoxCategory(ComboBoxChonLoai); }
public void Test() { BoolClass boolClass = new BoolClass(); if (boolClass) { //Do something here } }
IEnumerator TurnOffBool(float time, BoolClass boolClass) { //Detta är bara en timer för att stänga av en bool - Max //anledningen till varför det är en class med en bool istället för bara en bool är //för att med en class får man en referens till just den boolen som jag vill ändra och kan ändra just den - Max yield return(new WaitForSeconds(time)); boolClass.drawThisBox = false; }
public void BinaryBoolClosureGetsParameter() { var target = MakeTarget(); var boolClass = new BoolClass { IsFoo = true }; Expression <Func <BoolClass, bool> > pred = b => b.IsFoo == boolClass.IsFoo; var result = target.GenerateSql(new[] { pred }, null); Assert.Equal(" where ([IsFoo] = @l_1)", result.Sql); }
private void ButtonSuaThongTinHang_Click(object sender, EventArgs e) { int Id; try { Id = int.Parse(ListShow.SelectedItems[0].SubItems[1].Text); } catch (Exception ex) { return; } BoolClass boolClass = new BoolClass(); boolClass.isChanged = false; Medicine medicine1 = null; foreach (var medicine in MedicineHelper.GetMedicines()) { if (medicine.ID_Medicine == Id) { medicine1 = medicine; medicine1.ID_Category = new List <int?>(); medicine1.Name_Category = new List <string>(); foreach (var category in MedicineHelper.GetCategoryOfTheMedicine(medicine.ID_Medicine)) { medicine1.ID_Category.Add(category.CategoryID); medicine1.Name_Category.Add(category.NameCategory); } break; } } ChangeInformationMedicine changeInformationMedicine = new ChangeInformationMedicine(medicine1, boolClass); changeInformationMedicine.ShowDialog(); if (boolClass.isChanged == false) { return; } else { MedicineHelper.UpdateMedicine(medicine1, Id); MedicineHelper.UpdateCategoryWithMedicine(medicine1); } ListShow.Items.Clear(); //button1_Click(PictureBoxDanhMucSanPham, null); Init(); //ComboBoxChonLoai_SelectedValueChanged(ComboBoxChonLoai, null); SelectShowList(ListShow, new EventArgsForMedicine { Id = Id }); }
private void buttonThemCongTy_Click(object sender, EventArgs e) { BoolClass boolClass = new BoolClass { isChanged = false }; ThemCongTy themCongTy = new ThemCongTy(boolClass); themCongTy.ShowDialog(); if (boolClass.isChanged = true) { InitilizeManufaturerComboBox(); } }
private void ItemThemNhanVien_Click(object sender, EventArgs e) { BoolClass boolClass = new BoolClass(); boolClass.isChanged = false; Manager manager = new Manager(); ThemNhanVienForm themNhanVienForm = new ThemNhanVienForm(manager, boolClass); themNhanVienForm.ShowDialog(); if (boolClass.isChanged == true) { PictureBoxDanhSachNhanVien_Click(PictureBoxDanhSachNhanVien, null); } }
private void ItemThemNhanVien_Click() { BoolClass boolClass = new BoolClass(); boolClass.isChanged = false; Manager manager = new Manager(); ThemNhanVienForm themNhanVienForm = new ThemNhanVienForm(manager, boolClass); themNhanVienForm.ShowDialog(); if (boolClass.isChanged == true) { Load(); } }
public ChangeInformationManager(Manager manager, BoolClass boolClass) { InitializeComponent(); TextBoxMaNhanVien.Text = manager.ID_Manager.ToString(); TextBoxTenNhanVien.Text = manager.Name_Manager; TextBoxEmail.Text = manager.Email; TextBoxDienThoai.Text = manager.Phone; //TextBoxMatKhau.Text = manager.Password; textBoxNgayVaoLam.Text = manager.DayWork.Day.ToString(); textBoxThangVaoLam.Text = manager.DayWork.Month.ToString(); textBoxNamVaoLam.Text = manager.DayWork.Year.ToString(); textBoxLuong.Text = manager.Salary.ToString(); comboBoxGioiTinh.SelectedItem = manager.Sex ? comboBoxGioiTinh.Items[0] : comboBoxGioiTinh.Items[1]; check = boolClass; this.manager = manager; }
public ChangeInformationMedicine(Medicine medicine, BoolClass check) { InitializeComponent(); control = new CategoryListBoxControl(medicine); control.SetBounds(200, 10, control.Width, control.Height); this.Controls.Add(control); control.BringToFront(); TextBoxMaSanPham.Text = medicine.ID_Medicine.ToString(); TextBoxMaSanPham.ReadOnly = true; TextBoxTenSanPham.Text = medicine.Name_Medicine; //TextBoxNgayHetHan.Text = medicine.Expiry_Date.Value.Day.ToString(); //TextBoxNamHetHan.Text = medicine.Expiry_Date.Value.Year.ToString(); //TextBoxThangHetHan.Text = medicine.Expiry_Date.Value.Month.ToString(); TextBoxSoLuongCon.Text = medicine.Remain_Amount.ToString(); TextBoxXuatXu.Text = medicine.Source; //TextBoxNgaySanXuat.Text = medicine.Date_Of_Manufacture.Value.Day.ToString(); //TextBoxThangSanXuat.Text = medicine.Date_Of_Manufacture.Value.Month.ToString(); //TextBoxNamSanXuat.Text = medicine.Date_Of_Manufacture.Value.Year.ToString(); //TextBoxNgayNhap.Text = medicine.Import_Date.Value.Day.ToString(); //TextBoxThangNhap.Text = medicine.Import_Date.Value.Month.ToString(); //TextBoxNamNhap.Text = medicine.Import_Date.Value.Year.ToString(); TextBoxDongGoi.Text = medicine.Packing; TextBoxSoLuongTrongMoiGoi.Text = medicine.Unit; TextBoxGiaThanh.Text = medicine.Cost.ToString(); TextBoxMaDangKi.Text = medicine.Registration_Number.ToString(); this.medicine = medicine; this.Check = check; int i = 1; foreach (var item in MedicineHelper.GetImportHistory(medicine.ID_Medicine)) { ListViewItem listViewItem = new ListViewItem(new string[] { i.ToString(), item.Import_Date.ToString(), item.Date_Of_Manufacture.ToShortDateString(), item.Expiry_Date.ToShortDateString(), item.ID_Import.ToString() }); ListImport.Items.Add(listViewItem); i++; } }
public ThemNhanVienForm(Manager manager, BoolClass boolClass) { InitializeComponent(); //TextBoxTenNhanVien.Text = manager.Name_Manager; //TextBoxEmail.Text = manager.Email; //TextBoxDienThoai.Text = manager.Phone; //TextBoxMatKhau.Text = manager.Password; check = boolClass; this.manager = manager; // init the combobox choose sex ComboBoxItem item1 = new ComboBoxItem { Text = "Nam", Value = 1 }; ComboBoxItem item2 = new ComboBoxItem { Text = "Nữ", Value = 0 }; comboBox1.Items.Add(item1); comboBox1.Items.Add(item2); }
private void ItemThem_Click(object sender, EventArgs e) { BoolClass boolClass = new BoolClass(); boolClass.isChanged = false; ThemSanPhamForm themSanPhamForm = new ThemSanPhamForm(boolClass); themSanPhamForm.ShowDialog(); if (boolClass.isChanged == true) { ListShow.Items.Clear(); try { int selected = (ComboBoxChonLoai.SelectedItem as DataRowView).Row.Field <int>("ID_Category"); string query = "select * from Medicine a left join Category b on a.ID_Category = b.ID_Category where b.ID_Category = @value"; using (SqlConnection sqlConnection = new SqlConnection(Form1.connect)) { SqlCommand sqlCommand = new SqlCommand(query, sqlConnection); sqlCommand.Parameters.AddWithValue("value", selected); using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand)) { DataTable dataTable = new DataTable(); sqlDataAdapter.Fill(dataTable); ListShow.Items.Clear(); int i = 1; foreach (DataRow item in dataTable.Rows) { ListViewItem listViewItem = new ListViewItem(new string[] { i.ToString(), item.Field <int>("Id_Medicine").ToString(), item.Field <string>("Name_Medicine"), item.Field <int>("Amount").ToString(), item.Field <DateTime>("Experition_Date").ToString() }); ListShow.Items.Add(listViewItem); i++; } } } } catch (Exception ex) { } } }
public void CaseSensitiveFunc(boolClass boolArg, BoolClass BoolArg) { }
public ThemCongTy(BoolClass value) { InitializeComponent(); Value = value; }
private void ThayDoiThongTinNhanVien_Click(object sender, EventArgs e) { int Id; try { Id = int.Parse(ListViewDanhSachNhanVien.SelectedItems[0].SubItems[1].Text); } catch (Exception ex) { return; } using (SqlConnection sqlConnection = new SqlConnection(Form1.connect)) { string query = "select * from Manager where ID_Manager = @value"; SqlCommand sqlCommand = new SqlCommand(query, sqlConnection); sqlCommand.Parameters.AddWithValue("value", Id); using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand)) { DataTable dataTable = new DataTable(); sqlDataAdapter.Fill(dataTable); Manager manager = new Manager { Email = dataTable.Rows[0].Field <string>("Email"), ID_Manager = dataTable.Rows[0].Field <int>("ID_Manager"), Name_Manager = dataTable.Rows[0].Field <string>("Name_Manager"), Password = dataTable.Rows[0].Field <string>("Password"), Phone = dataTable.Rows[0].Field <string>("Phone"), Image = dataTable.Rows[0].Field <string>("Image"), DayWork = dataTable.Rows[0].Field <DateTime>("Day_Work"), Salary = dataTable.Rows[0].Field <decimal>("Salary"), Sex = dataTable.Rows[0].Field <bool>("Sex") }; BoolClass boolClass = new BoolClass(); boolClass.isChanged = false; ChangeInformationManager changeInformationManager = new ChangeInformationManager(manager, boolClass); changeInformationManager.ShowDialog(); if (boolClass.isChanged == false) { return; } else { sqlConnection.Open(); string query1 = "update Manager set Name_Manager = @name, " + "Phone = @phone, " + "Email = @email " + ",Password = @password " + ",Day_Work = @daywork " + ",Salary = @salary " + ",Sex = @sex " + "where ID_Manager = @old_Id"; SqlCommand sqlCommand1 = new SqlCommand(query1, sqlConnection); sqlCommand1.Parameters.AddWithValue("name", manager.Name_Manager); sqlCommand1.Parameters.AddWithValue("Phone", manager.Phone); sqlCommand1.Parameters.AddWithValue("Email", manager.Email); sqlCommand1.Parameters.AddWithValue("Password", manager.Password); sqlCommand1.Parameters.AddWithValue("daywork", manager.DayWork); sqlCommand1.Parameters.AddWithValue("salary", manager.Salary); sqlCommand1.Parameters.AddWithValue("sex", manager.Sex); sqlCommand1.Parameters.AddWithValue("old_Id", Id); sqlCommand1.ExecuteScalar(); } } ListViewDanhSachNhanVien.Items.Clear(); PictureBoxDanhSachNhanVien_Click(PictureBoxDanhSachNhanVien, null); ListViewDanhSachNhanVien_SelectedIndexChanged(ListViewDanhSachNhanVien, null); } }
public ThemSanPhamForm(BoolClass boolClass) { InitializeComponent(); this.boolClass = boolClass; ShowMedicines.InitComboBoxCategory(ComboBoxLoaiHang); }
public ThemLoaiHang(BoolClass value) { InitializeComponent(); Value = value; }
public Expression(string txt, string block, Statement statement) { txt = txt.Trim(); Txt = txt; Block = block; Statement = statement; CallFunctionReturn = null; AwaitReturn = false; Lib = Statement.Lib; var binaryOperators = _tokens[0] .OrderByDescending(x => x.Length) .ToArray(); var unitaryOperators = _tokens[1] .OrderByDescending(x => x.Length) .ToArray(); if (int.TryParse(txt, out _)) { Type = EType.Int; var p = txt; Exec = () => { var value = p.GetInt(); var i = new IntClass(value); return(i); }; return; } if (GetStr(txt, out var qtxt)) { if (qtxt.Length == txt.Length - 2) { Type = EType.Str; Exec = () => { var value = qtxt.GetStr(); var s = new StrClass(value); return(s); }; return; } } if (bool.TryParse(txt, out var valueBool)) { Type = EType.Bool; Exec = () => { var value = new BoolClass(valueBool); return(value); }; return; } if (txt.StartsWith("new")) { var ident = txt.Substring(3); if (GetStr(ident, out var brackets, '(', ')')) { CustomClass customClass = null; var i = ident.IndexOf("(" + brackets + ")", StringComparison.Ordinal); var identWb = ident.Remove(i, brackets.Length + 2).Trim(); var parametersExpresions = new List <Expression>(); if (!string.IsNullOrWhiteSpace(brackets)) { var parametersTxt = brackets.Split(','); foreach (var parantese in parametersTxt) { var paranteseTrim = parantese.Trim(); var expresion = new Expression(paranteseTrim, Block, Statement); parametersExpresions.Add(expresion); } } Exec = () => { if (!AwaitReturn) { var parametersValue = parametersExpresions.Select(x => x.GetValue()).ToList(); customClass = Memory.GetClass(identWb, Block).Clone(); customClass.Assign(parametersValue); AwaitReturn = true; return(new Return(null, Flag.Function)); } else { AwaitReturn = false; return((IClass)customClass); } }; } return; } var l = txt.First() == '('; var f = txt.Last() == ')'; if (l && f) { txt = txt.Substring(1, txt.Length - 2); Type = EType.Par; var exp = new Expression(txt, Block, Statement); Exec = exp.Exec; return; } foreach (var @operator in unitaryOperators) { if (txt.StartsWith(@operator)) { Type = EType.None; var len = @operator.Length; var exprTxt = txt.Substring(len, txt.Length - len); var expr = new Expression(exprTxt, Block, Statement); if (@operator == "-") { Exec = () => { var value = expr.GetValue(); if (value is int i) { value = -i; } if (value is string s) { if (s[0] == '-') { value = s.Substring(1, s.Length - 1); } else { value = "-" + s; } } if (expr.Type == EType.Ind) { var variable = expr.Exec().ToString(); var variable1 = Memory.GetVariable(variable, Block); if (value is string ss) { variable1.SetValue(ss); } if (value is int ii) { variable1.SetValue(ii); } } return(value); }; return; } if (@operator == "!") { Exec = () => { var value = expr.GetValue(); if (value is int i) { value = i ^ int.MaxValue; } if (value is string s) { if (char.IsLower(s, 0)) { value = s.ToUpper(); } else { value = s.ToLower(); } } if (expr.Type == EType.Ind) { var variable = expr.Exec().ToString(); var variable1 = Memory.GetVariable(variable, Block); if (value is string ss) { variable1.SetValue(ss); } if (value is int ii) { variable1.SetValue(ii); } } return(value); }; return; } if (@operator == "++") { Exec = () => { var value = expr.GetValue(); if (value is int i) { value = i + 1; } if (value is string s) { value = s.ToUpper(); } if (expr.Type == EType.Ind) { var variable = expr.Exec().ToString(); var variable1 = Memory.GetVariable(variable, Block); if (value is string ss) { variable1.SetValue(ss); } if (value is int ii) { variable1.SetValue(ii); } } return(value); }; return; } if (@operator == "--") { Exec = () => { var value = expr.GetValue(); if (value is int i) { value = i - 1; } if (value is string s) { value = s.ToLower(); } if (expr.Type == EType.Ind) { var variable = expr.Exec().ToString(); var variable1 = Memory.GetVariable(variable, Block); if (value is string ss) { variable1.SetValue(ss); } if (value is int ii) { variable1.SetValue(ii); } } return(value); }; return; } return; } else if (txt.EndsWith(@operator)) { Type = EType.None; var len = @operator.Length; var exprTxt = txt.Substring(0, txt.Length - len); var expr = new Expression(exprTxt, Block, Statement); if (@operator == "++") { Exec = () => { var value = expr.GetValue(); if (value is int i) { value = i + 1; } if (value is string s) { value = s.ToUpper(); } if (expr.Type == EType.Ind) { var variable = expr.Exec().ToString(); var variable1 = Memory.GetVariable(variable, Block); if (value is string ss) { variable1.SetValue(ss); } if (value is int ii) { variable1.SetValue(ii); } } return(value); }; return; } if (@operator == "--") { Exec = () => { var value = expr.GetValue(); if (value is int i) { value = i - 1; } if (value is string s) { value = s.ToLower(); } if (expr.Type == EType.Ind) { var variable = expr.Exec().ToString(); var variable1 = Memory.GetVariable(variable, Block); if (value is string ss) { variable1.SetValue(ss); } if (value is int ii) { variable1.SetValue(ii); } } return(value); }; return; } } } var ops = new List <(int i, int l, string o)>(); foreach (var @operator in binaryOperators) { for (int i = txt.IndexOf(@operator, StringComparison.Ordinal); i > -1; i = txt.IndexOf(@operator, i + 1, StringComparison.Ordinal)) { var toAdd = (i, @operator.Length, @operator); var add = true; foreach (var op in ops) { var overlap = toAdd.i < op.i + op.l && op.i < toAdd.i + toAdd.Length; if (overlap) { add = false; break; } } if (add) { ops.Add(toAdd); } } } ops = ops.OrderBy(x => { if (priority.Contains(x.o)) { return(0); } else { return(x.i); } }).ToList(); var exprsStr = txt.Split(binaryOperators, 2, StringSplitOptions.None); if (exprsStr.Length > 1) { var op = txt.Substring(ops[0].i, ops[0].l); var p = txt.IndexOf('('); if (p > ops[0].i || p == -1) { var exps1 = txt.Substring(0, ops[0].i); var exps2 = txt.Substring(ops[0].i + 1 + ops[0].l); var exp1 = new Expression(exps1, Block, Statement); var exp2 = new Expression(exps2, Block, Statement); Type = EType.Asg; SetOperation(op, exp1, exp2); return; } } if (GetStr(Txt, out var paranteses, '(', ')')) { Type = EType.Func; var indexOfParant = Txt.IndexOf('(' + paranteses + ')', StringComparison.Ordinal); var function = Txt.Substring(0, indexOfParant).Trim(); var parametersExpresions = new List <Expression>(); if (!string.IsNullOrWhiteSpace(paranteses)) { parametersExpresions = paranteses.Split(',') .Select(x => new Expression(x.Trim(), Block, Statement)) .ToList(); } if (function.Contains(".")) { var classAccess = function; var exprClassAccess = new Expression(classAccess, block, Statement); Exec = () => { if (!AwaitReturn) { var value = exprClassAccess.GetValue(); if (value is Function func) { var parameters = parametersExpresions.Select(x => x.GetValue()).ToList(); Lib.AccessNewFunction(func, parameters); AwaitReturn = true; } else if (value is Variable variable) { if (variable.Type == typeof(Function)) { var func2 = (Function)variable.GetValue(); var parameters = parametersExpresions.Select(x => x.GetValue()).ToList(); Lib.AccessNewFunction(func2, parameters); AwaitReturn = true; } } return(null); } else { CallFunctionReturn = Lib.GetReturn(); AwaitReturn = false; if (CallFunctionReturn is null) { return(new Return()); } else if (CallFunctionReturn is Return r) { return(r.Value); } else { return(CallFunctionReturn); } } }; return; } else { Exec = () => { if (!AwaitReturn) { AwaitReturn = true; var parameters = parametersExpresions.Select(x => x.GetValue()).ToList(); Lib.AccessNewFunction(function, parameters); return(new Return(null, Flag.Function)); } else { CallFunctionReturn = Lib.GetReturn(); AwaitReturn = false; if (CallFunctionReturn is null) { return(new Return()); } else if (CallFunctionReturn is Return r) { return(r.Value); } else { return(CallFunctionReturn); } } }; } return; } if (Txt.Contains(".")) { Type = EType.Cls; var dotIndex = Txt.LastIndexOf('.'); var split = Txt.SplitAtIndex(dotIndex); var second = split[1].Substring(1); var exprTxt = split[0]; var expr = new Expression(exprTxt, block, Statement); Exec = () => { var value = expr.GetValue(); if (value is IClass @class) { return(@class.Get(second)); } return(null); }; return; } Type = EType.Ind; Exec = () => GetIdentifier(txt); }