private void btnSaveNew_Click(object sender, EventArgs e) { if (saveData()) { GearModel = new GearModel(); loadData(); } }
private void Awake() { rb = GetComponent <Rigidbody>(); ins = this; //serialize this //250 pullspeed for addforce //10 pullspeed for velo model = new GearModel(0.01f, 500f, 7f); rb.isKinematic = true; // pooler.Preload(Instantiate(hook, transform.position, Quaternion.Euler(Vector3.zero)) as GameObject, 4); pooler.Preload(hook, 4); tempLeft = left; tempRight = right; }
private void btnEdit_Click(object sender, EventArgs e) { int id = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)); if (id == 0) { return; } GearModel model = (GearModel)GearBO.Instance.FindByPK(id); int catId = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colWipGCQT)); _rownIndex = grvData.FocusedRowHandle; frmGearDetail frm = new frmGearDetail(); frm.GearModel = model; if (frm.ShowDialog() == DialogResult.OK) { LoadInfoSearch(); } }
private void loadGear(string hypCode) { Expression exp = new Expression("HYP", hypCode); ArrayList arr = GearBO.Instance.FindByExpression(exp); if (arr.Count > 0) { GearModel gear = arr[0] as GearModel; _arrGear = new ArrayList(); _arrGear.Add(TextUtils.ToString(gear.Gear1)); _arrGear.Add(TextUtils.ToString(gear.Gear2)); _arrGear.Add(TextUtils.ToString(gear.Gear3)); if (_arrGear.Count > 0) { cboGear.DataSource = _arrGear; cboGear.SelectedIndex = 0; } else { cboGear.SelectedIndex = -1; } } }
protected GearFacade(GearModel model) : base(model) { }
private bool GenerateByHpy(int qty) { if (_hypCode == "") { MessageBox.Show("HYP không được để trống"); return(false); } DataTable dtGearWorking = TextUtils.LoadDataFromSP("spGetGearWorking_ByHypCode", "A", new string[] { "@HYP" }, new object[] { _hypCode }); Expression exp = new Expression("HYP", _hypCode); ArrayList arr = GearBO.Instance.FindByExpression(exp); // Từ các hạng mục kiểm tra sinh ra các cột _countGearWorking = dtGearWorking.Rows.Count; //Đầu tiên bỏ các dòng hiện tại đang có trên danh sách đi grvData.Rows.Clear(); //Xóa các cột có tag Value List <int> lstColumnTag = new List <int>(); for (int i = 0; i < grvData.Columns.Count; i++) { DataGridViewColumn col = grvData.Columns[i]; if (col.Tag != null && col.Tag.ToString() != "") { lstColumnTag.Add(col.Index); } } for (int i = lstColumnTag.Count - 1; i >= 0; i--) { grvData.Columns.Remove(grvData.Columns[lstColumnTag[i]]); } //add tiếp 4 dòng for (int i = 0; i < 4; i++) { grvData.Rows.Add(); } grvData.Rows[0].Cells[0].Value = "Tiêu chuẩn"; grvData.Rows[1].Cells[0].Value = "MIN"; grvData.Rows[2].Cells[0].Value = "MAX"; grvData.Rows[3].Cells[0].Value = "Tần suất"; if (_countGearWorking == 0 || arr.Count <= 0) { MessageBox.Show("Bạn phải nhập đúng HYP!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } GearModel gear = arr[0] as GearModel; _qtyImage = gear.QtyImage; _qtyAudio = gear.QtyAudio; if (qty <= 5) { _qtyImage += 2; } for (int i = _countGearWorking - 1; i >= 0; i--) { DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn(); col.HeaderText = TextUtils.ToString(dtGearWorking.Rows[i]["WorkingName"]); //Tên của GearWorking col.Tag = TextUtils.ToString(dtGearWorking.Rows[i]["ID"]) + ";" + TextUtils.ToString(dtGearWorking.Rows[i]["SortOrder"]); //Cái này để lưu lại ID của GearWorking col.DataPropertyName = TextUtils.ToString(dtGearWorking.Rows[i]["SortOrder"]); //cho stt vào col.Width = 70; col.SortMode = DataGridViewColumnSortMode.NotSortable; col.Name = "col" + i; grvData.Columns.Insert(3, col); // Cập nhật thông tin dữ liệu 4 dòng dữ liệu với giá trị tiêu chuẩn tương ứng với mỗi cột hạng mục grvData.Rows[0].Cells[3].Value = TextUtils.ToDecimal(dtGearWorking.Rows[i]["DefaultValue"]); grvData.Rows[1].Cells[3].Value = TextUtils.ToDecimal(dtGearWorking.Rows[i]["MinValue"]); grvData.Rows[2].Cells[3].Value = TextUtils.ToDecimal(dtGearWorking.Rows[i]["MaxValue"]); grvData.Rows[3].Cells[3].Value = TextUtils.ToString(dtGearWorking.Rows[i]["TanSuat"]); grvData.Rows[0].Cells[3].Style.BackColor = _mauCarot; grvData.Rows[1].Cells[3].Style.BackColor = _mauCarot; grvData.Rows[2].Cells[3].Style.BackColor = _mauCarot; grvData.Rows[3].Cells[3].Style.BackColor = _mauTanSuat; } for (int i = _qtyAudio; i >= 1; i--) { DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn(); col.HeaderText = "Âm thanh " + i; //Tên của GearWorking //col.Tag = TextUtils.ToString(dtGearWorking.Rows[i]["ID"]) + ";" + TextUtils.ToString(dtGearWorking.Rows[i]["SortOrder"]);//Cái này để lưu lại ID của GearWorking //col.DataPropertyName = i.ToString();//cho stt vào col.DataPropertyName = "audio"; col.Tag = i; col.Width = 50; col.SortMode = DataGridViewColumnSortMode.NotSortable; col.Name = "colAudio" + i; col.DefaultCellStyle.ForeColor = Color.Blue; grvData.Columns.Insert(colResult1.Index + 1, col); } for (int i = _qtyImage; i >= 1; i--) { DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn(); col.HeaderText = "Ảnh " + i; //Tên của GearWorking //col.Tag = TextUtils.ToString(dtGearWorking.Rows[i]["ID"]) + ";" + TextUtils.ToString(dtGearWorking.Rows[i]["SortOrder"]);//Cái này để lưu lại ID của GearWorking col.DataPropertyName = "image"; //cho stt vào col.Tag = i; col.Width = 50; col.SortMode = DataGridViewColumnSortMode.NotSortable; col.Name = "colImage" + i; col.DefaultCellStyle.ForeColor = Color.Blue; grvData.Columns.Insert(colResult1.Index + 1 + _qtyAudio, col); } grvData.Rows[0].ReadOnly = true; grvData.Rows[1].ReadOnly = true; grvData.Rows[2].ReadOnly = true; grvData.Rows[3].ReadOnly = true; return(true); }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { int rowCount = grvData.RowCount; GearModel gear; GearWorkingModel gearWorking; int col = grvData.Columns.Count; int gearID; for (int i = 0; i < rowCount; i++) { if (i < 2) { continue; } progressBar1.Invoke((Action)(() => { progressBar1.Value = i - 1; })); txtRate.Invoke((Action)(() => { txtRate.Text = string.Format("{0}/{1}", i - 1, rowCount - 2); })); string HYPCode = Lib.ToString(grvData.GetRowCellValue(i, "F2")); Expression exp = new Expression("HYP", HYPCode); ArrayList arr = GearBO.Instance.FindByExpression(exp); if (arr.Count > 0) { gear = arr[0] as GearModel; } else { gear = new GearModel(); } // update gear gear.HYP = Lib.ToString(grvData.GetRowCellValue(i, "F2")); gear.Gear1 = Lib.ToString(grvData.GetRowCellValue(i, "F3")); gear.Gear2 = Lib.ToString(grvData.GetRowCellValue(i, "F4")); gear.Gear3 = Lib.ToString(grvData.GetRowCellValue(i, "F5")); gear.Lap = Lib.ToString(grvData.GetRowCellValue(i, "F6")); gear.LotSize = Lib.ToInt(grvData.GetRowCellValue(i, "F7")); gear.GThieu = Lib.ToInt(grvData.GetRowCellValue(i, "F8")); gear.GGiaCongThem = Lib.ToInt(grvData.GetRowCellValue(i, "F9")); gear.WipG = Lib.ToInt(grvData.GetRowCellValue(i, "F10")); gear.QtyImage = Lib.ToInt(grvData.GetRowCellValue(i, "F11")); gear.QtyAudio = 2; if (arr.Count > 0) { // update Gear GearBO.Instance.Update(gear); gearID = gear.ID; } else { gearID = (int)GearBO.Instance.Insert(gear); } for (int j = 0; j < col; j++) { string sortOrder = Lib.ToString(grvData.GetRowCellValue(1, grvData.Columns[j])); if (string.IsNullOrWhiteSpace(sortOrder)) { continue; } Expression exp1 = new Expression("gearID", gearID); Expression exp2 = new Expression("SortOrder", TextUtils.ToInt(sortOrder)); ArrayList arrGW = GearWorkingBO.Instance.FindByExpression(exp1.And(exp2)); if (arrGW.Count > 0) { gearWorking = arrGW[0] as GearWorkingModel; } else { gearWorking = new GearWorkingModel(); } string value = Lib.ToString(grvData.GetRowCellValue(i, grvData.Columns[j])); gearWorking.GearID = gearID; gearWorking.MaxValue = TextUtils.ToDecimal(value); gearWorking.MinValue = 0; gearWorking.WorkingName = Lib.ToString(grvData.GetRowCellValue(0, grvData.Columns[j])); gearWorking.CheckValueType = 1; gearWorking.ValueType = 1; gearWorking.SortOrder = TextUtils.ToInt(sortOrder); gearWorking.TanSuat = "1/5"; gearWorking.DefaultValue = (gearWorking.MaxValue + gearWorking.MinValue) / 2; if (value.Contains('-')) { decimal minValue = TextUtils.ToDecimal(value.Split('-')[0]); decimal maxValue = TextUtils.ToDecimal(value.Split('-')[1]); gearWorking.MaxValue = maxValue; gearWorking.MinValue = minValue; gearWorking.DefaultValue = (gearWorking.MaxValue + gearWorking.MinValue) / 2; } if (arrGW.Count > 0) { GearWorkingBO.Instance.Update(gearWorking); } else { GearWorkingBO.Instance.Insert(gearWorking); } } } }
//[STAThread] static void Main() { GearModel model = new GearModel(); GLGameApplication app = new GLGameApplication("Gears", new Rectangle(10, 10, 400, 300), true); app.Run(model); }