private void buttonTaoMoi_Click(object sender, EventArgs e) { if (textBoxTenBanVe.Text.Equals("")) { MessageBox.Show("Chưa nhập tên hộ chiếu"); return; } foreach (RadioButton value in radioButtonTemplate) { if (value.Checked) { idTemplate = value.Name; pathTemplate = BS_Template.ChonTemplate(idTemplate).DuongDan; } } //tạo id hộ chiếu, gán cho biến toàn cục String idHoChieu = BS_HoChieu.TaoHoChieu(idTemplate, textBoxTenBanVe.Text); if (idHoChieu == null) { MessageBox.Show("Hộ chiếu đã có"); return; } else { MyGetData(idHoChieu); this.Close(); } }
public void TestInsert( ) { var k = 0; for (var i = 0; i < 100; i++) { Task.Factory.StartNew(() => { try { GlobalVar.DbHelper.BeginTransaction(); var model = new BS_Template { id = Guid.NewGuid().ToString(), code = k.ToString(), name = "测试" + k, remarks = "测试" + k, type = "1" }; Insert(model); GlobalVar.DbHelper.CommitTransaction(); k++; } catch (Exception ex) { GlobalVar.DbHelper.RollbackTransaction(); TyLog.WriteError(ex.Message); } }); } }
/// <summary> /// 绑定列表 /// </summary> private void BindList() { try { dataGridView1.DataSource = null; var t = new BS_Template { name = textBox1.TextLength == 0 ? "" : textBox1.Text }; object[] objs = { TyConvert.ObjToJson(t), pagerControl1.PageSize, pagerControl1.Page }; var res = _ts.Fun("GetTemplateList", TyConvert.ObjToJson(objs)); if (string.IsNullOrEmpty(res)) { return; } var ress = TyConvert.JsonToObj <string[]>(res); pagerControl1.TotalRows = int.Parse(ress[0]); dataGridView1.ClearSelection(); dataGridView1.Columns.Clear(); dataGridView1.AutoGenerateColumns = false; var dc = new DataGridViewTextBoxColumn { HeaderText = @"ID", Width = 240, DataPropertyName = "id" }; dataGridView1.Columns.Add(dc); dc = new DataGridViewTextBoxColumn { HeaderText = @"编码", DataPropertyName = "code" }; dataGridView1.Columns.Add(dc); dc = new DataGridViewTextBoxColumn { HeaderText = @"名称", DataPropertyName = "name", Width = 240 }; dataGridView1.Columns.Add(dc); dc = new DataGridViewTextBoxColumn { HeaderText = @"备注", DataPropertyName = "remarks" }; dataGridView1.Columns.Add(dc); dataGridView1.ReadOnly = true; dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridView1.DataSource = TyConvert.JsonToObj <List <BS_Template> >(ress[1]); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void FormThongTinBanVe_Load(object sender, EventArgs e) { if (idHoChieu == null) { MessageBox.Show("Thông tin hộ chiếu chưa được lưu trong CSDL"); this.Close(); return; } BanVe value = BS_BanVe.BanVe(BS_HoChieu.HoChieu(idHoChieu).MaBanVe); labelValue_TenBanVe.Text = value.TenBanVe; labelValue_Template.Text = BS_Template.ChonTemplate(value.Template).TenTemplate; labelValue_NgayChinhSua.Text = value.NgayChinhSua; labelValue_SoLoKhoan.Text = BS_LoKhoan.DanhSachLoKhoan(idHoChieu).Count.ToString(); }
//测试新增 private void button1_Click(object sender, EventArgs e) { int k = 0; for (int i = 0; i < 100; i++) { Task.Factory.StartNew(new Action(() => { try { DBHelper.BeginTransaction(); BS_Template model = new BS_Template(); model.id = m_TemplateDal.GetMaxId().ToString(); model.code = k.ToString("0000"); model.name = "测试" + k.ToString(); model.remarks = "测试" + k.ToString(); model.type = ((int)Enums.TemplateType.Notice).ToString(); m_TemplateDal.Insert(model); //throw new Exception("a"); BS_Test test = new BS_Test(); test.id = m_TestDal.GetMaxId().ToString(); test.code = "测试" + k.ToString(); test.name = "测试" + k.ToString(); test.remarks = "测试" + k.ToString(); m_TestDal.Insert(test); DBHelper.CommitTransaction(); k++; if (k == 100) { MessageBox.Show("插入数据成功"); this.Invoke(new InvokeDelegate(() => { BindList(); })); } } catch (Exception ex) { DBHelper.RollbackTransaction(); MessageBox.Show(ex.Message); } })); } }
/// <summary> /// 分页获取模板集合 /// </summary> public List <BS_Template> GetList(BS_Template b, int size, int page, out int rows) { var sql = new StringBuilder(@" select * from BS_Template t where 1=1 "); if (!string.IsNullOrWhiteSpace(b.name)) { sql.AppendFormat(" and t.name like '%{0}%'", b.name); } var orderby = string.Empty; var list = GlobalVar.DbHelper.FindPageBySql <BS_Template>(sql.ToString(), orderby, size, page, out rows); return(list); }
private void FormBanVeMoi_Load(object sender, EventArgs e) { List <Template> danhSachTemplate = BS_Template.DanhSachTemplate(); int i = 1, x = 10, y = 5; foreach (Template value in danhSachTemplate) { RadioButton rbt = new RadioButton(); //rbt.Name = "radioButton" + i.ToString(); rbt.Name = value.ID; rbt.Location = new Point(x, y); rbt.Appearance = System.Windows.Forms.Appearance.Button; rbt.Size = new Size(160, 90); rbt.FlatStyle = FlatStyle.Flat; rbt.FlatAppearance.BorderSize = 3; rbt.BackgroundImageLayout = ImageLayout.Stretch; rbt.Text = value.TenTemplate; rbt.ForeColor = Properties.Settings.Default.SecondaryColor; rbt.TextAlign = ContentAlignment.TopLeft; rbt.Cursor = Cursors.Hand; if (!value.AnhMau.Equals("")) { rbt.BackgroundImage = Image.FromFile(value.AnhMau); } radioButtonTemplate.Add(rbt); panelMain.Controls.Add(rbt); //UserControl_PreviewButton previewButton = new UserControl_PreviewButton(value.TenTemplate, value.AnhMau, value.DuongDan); //previewButton.Name = "radioButton" + i.ToString(); //previewButton.Location = new Point(x, y); //panel1.Controls.Add(previewButton); if (i % 2 == 0) { x = x + 170; y = 5; } else { y = y + 100; } i++; } foreach (RadioButton rb in radioButtonTemplate) { rb.FlatAppearance.BorderSize = 2; rb.CheckedChanged += new System.EventHandler(radioButtonTempGroups_CheckedChanged); } }
private void loadFile_FormMoBanVeDatabase(String idHoChieu) { this.hoChieuChinh = BS_HoChieu.HoChieu(idHoChieu); this.banVeChinh = BS_BanVe.BanVe(this.hoChieuChinh.MaBanVe); List <LoKhoan> danhSachLoKhoan = BS_LoKhoan.DanhSachLoKhoan(idHoChieu); List <Circle> danhSachCircle = new List <Circle>(); mgCircles = new ManageCircle(); //dựng bản vẽ mới //this.banVeChinh.HienKhoangCach = false; this.Text = "Bản vẽ: [" + this.banVeChinh.TenBanVe + "]"; Lcad.DrwLoad(hDrw, BS_Template.ChonTemplate(this.banVeChinh.Template).DuongDan, this.Handle, hWnd); layerLoMin = Lcad.DrwAddLayer(hDrw, "LoMin", "cyan", 0, Lcad.LC_LWEIGHT_DEFAULT); layerLuoiKichThuoc = Lcad.DrwAddLayer(hDrw, "LuoiKichThuoc", "foreground", 0, Lcad.LC_LWEIGHT_DEFAULT); int hBlockModel = Lcad.PropGetHandle(hDrw, Lcad.LC_PROP_DRW_BLOCK_MODEL); foreach (LoKhoan value in danhSachLoKhoan) { int hEntCircle = Lcad.BlockAddCircle(hBlockModel, value.ToaDoX, value.ToaDoY, value.BanKinh, false); Lcad.PropPutInt(hEntCircle, Lcad.LC_PROP_ENT_ID, int.Parse(value.MaLoKhoan)); Lcad.PropPutInt(hEntCircle, Lcad.LC_PROP_ENT_KEY, keyCircle); Lcad.PropPutStr(hEntCircle, Lcad.LC_PROP_ENT_LAYER, "LoMin"); danhSachCircle.Add(new Circle(hEntCircle)); } mgCircles.AddListCircle(danhSachCircle); if (banVeChinh.HienKhoangCach) { Lcad.LayerClear(layerLuoiKichThuoc, hBlockModel); DungLuoiKichThuoc(); } //vẽ lại hình Lcad.DrwRegenViews(hDrw, 0); Lcad.WndExeCommand(hWnd, Lcad.LC_CMD_ZOOM_EXT, 0); BS_LiteCAD.ShowNotifyAutoHide(elementHost1, this.banVeChinh.TenBanVe + " - đã mở"); //mở form dựng lưới lỗ khoan if (mgCircles.GetListCircles().Count == 0) { FormXayDungLoKhoan fm = new FormXayDungLoKhoan(); fm.MyGetData = new FormXayDungLoKhoan.GetData(loadFile_FormXayDungLoKhoan); fm.Show(); } }
//测试删除 private void button3_Click(object sender, EventArgs e) { try { DBHelper.BeginTransaction(); foreach (DataGridViewRow dr in gridView.SelectedRows) { BS_Template old = (BS_Template)dr.DataBoundItem; m_TemplateDal.Del(Convert.ToInt32(old.id)); } DBHelper.CommitTransaction(); MessageBox.Show("删除成功"); BindList(); } catch (Exception ex) { DBHelper.RollbackTransaction(); MessageBox.Show("修改失败:" + ex.Message); } }
private void loadFile_FormBanVeMoi(String idHoChieu) { this.hoChieuChinh = BS_HoChieu.HoChieu(idHoChieu); this.banVeChinh = BS_BanVe.BanVe(this.hoChieuChinh.MaBanVe); mgCircles = new ManageCircle(); //dựng bản vẽ mới this.Text = "Hộ chiếu: [" + this.hoChieuChinh.TenHoChieu + "]"; Lcad.DrwLoad(hDrw, BS_Template.ChonTemplate(this.banVeChinh.Template).DuongDan, this.Handle, hWnd); layerLoMin = Lcad.DrwAddLayer(hDrw, "LoMin", "cyan", 0, Lcad.LC_LWEIGHT_DEFAULT); layerLuoiKichThuoc = Lcad.DrwAddLayer(hDrw, "LuoiKichThuoc", "foreground", 0, Lcad.LC_LWEIGHT_DEFAULT); //vẽ lại hình Lcad.DrwRegenViews(hDrw, 0); Lcad.WndExeCommand(hWnd, Lcad.LC_CMD_ZOOM_EXT, 0); //mở form dựng lưới lỗ khoan if (mgCircles.GetListCircles().Count == 0) { FormXayDungLoKhoan fm = new FormXayDungLoKhoan(); fm.MyGetData = new FormXayDungLoKhoan.GetData(loadFile_FormXayDungLoKhoan); fm.Show(); } }
//测试修改 private void button2_Click(object sender, EventArgs e) { Random rnd = new Random(); try { //DBHelper.BeginTransaction(); foreach (DataGridViewRow dr in gridView.SelectedRows) { BS_Template old = (BS_Template)dr.DataBoundItem; BS_Template model = m_TemplateDal.Get2(old.id, Enums.TemplateType.Notice); model.remarks = rnd.Next(1, 9999).ToString("0000"); m_TemplateDal.Update(model); } //DBHelper.CommitTransaction(); MessageBox.Show("修改成功"); BindList(); } catch (Exception ex) { DBHelper.RollbackTransaction(); MessageBox.Show("修改失败:" + ex.Message); } }
private void FormStart_Load(object sender, EventArgs e) { List <Template> danhSachTemplate = BS_Template.DanhSachTemplate(); int i = 1, x = 10, y = 10; foreach (Template value in danhSachTemplate) { RadioButton rbt = new RadioButton(); rbt.Name = value.ID; rbt.Location = new Point(x, y); rbt.Appearance = System.Windows.Forms.Appearance.Button; rbt.Size = new Size(160, 90); rbt.FlatStyle = FlatStyle.Flat; rbt.FlatAppearance.BorderSize = 3; rbt.BackgroundImageLayout = ImageLayout.Stretch; rbt.Text = value.TenTemplate; rbt.ForeColor = Properties.Settings.Default.FormBackgroundColor; rbt.TextAlign = ContentAlignment.TopLeft; rbt.Cursor = Cursors.Hand; if (!value.AnhMau.Equals("")) { rbt.BackgroundImage = Image.FromFile(value.AnhMau); } radioButtonTemplate.Add(rbt); panelMain.Controls.Add(rbt); if (i % 2 == 0) { x = 10; y = y + 100; } else { x = x + 170; } i++; } foreach (RadioButton rb in radioButtonTemplate) { rb.FlatAppearance.BorderSize = 2; rb.CheckedChanged += new System.EventHandler(radioButtonTempGroups_CheckedChanged); } danhSachHoChieu = BS_HoChieu.DanhSachHoChieuGanNhat(5); i = 0; foreach (HyperlinkLabelControl value in duongDanHoChieu) { if (danhSachHoChieu.Count > i) { value.Text = danhSachHoChieu[i].TenHoChieu; value.Click += new System.EventHandler(link_Click); i++; } } i = 0; foreach (Label value in ngayBanVe) { if (danhSachHoChieu.Count > i) { value.Text = BS_BanVe.BanVe(danhSachHoChieu[i].MaBanVe).NgayChinhSua; i++; } this.Refresh(); } }
/// <summary> /// 修改 /// </summary> public void Update(BS_Template obj) { GlobalVar.DbHelper.Update(obj, $"id = '{obj.id}'"); }
/// <summary> /// 添加 /// </summary> public void Insert(BS_Template obj) { GlobalVar.DbHelper.Insert(obj); }