private void initDataGridView() { this.dataGridView1.Rows.Clear(); for (int i = this.dataGridView1.Columns.Count - 1; i > 0; i--) { this.dataGridView1.Columns.RemoveAt(i); } sizeAttrs = ProductClothesDao.getInstance().findAttributes(productId, 2); foreach (ProductAttribute attr in sizeAttrs) { this.dataGridView1.Columns.Add(attr.ID.ToString(), attr.CharactorValue.Name); DataGridViewColumn column = this.dataGridView1.Columns[this.dataGridView1.Columns.Count - 1]; column.SortMode = DataGridViewColumnSortMode.NotSortable; column.Width = 80; } colorAttrs = ProductClothesDao.getInstance().findAttributes(productId, 1); foreach (ProductAttribute attr in colorAttrs) { this.dataGridView1.Rows.Add(new object[] { attr.CharactorValue.Name }); } if (sizeAttrs.Count <= 0 || colorAttrs.Count <= 0) { this.label1.Visible = true; } else { this.label1.Visible = false; } }
private void initProduct() { this.label4.Text = "编辑货品, ID:" + productID; Product product = ProductClothesDao.getInstance().FindByID(productID); this.textBox_name.Text = product.Name; this.textBox_price.Text = product.PricePurchase.ToString(); this.textBox_comment.Text = product.Comment; this.comboBoxTree1.setSelectNode(product.CategoryID.ToString()); this.pickValue_color.allToLeft(); this.pickValue_color.setSelectItems(ProductClothesDao.getInstance().findAttributes(productID, 1)); this.pickValue_size.allToLeft(); this.pickValue_size.setSelectItems(ProductClothesDao.getInstance().findAttributes(productID, 2)); if (ProductClothesCirculationRecordDao.getInstance().FindCount(productID) > 0) { this.setPickValue(false); } else { this.setPickValue(true); } attributeChanged = false; }
protected override DataTable getRecordsTable(int parentId, string name) { Category parent = CategoryDao.getInstance().FindById(conf.CategoryTableName, parentId); DataTable dataTable = ProductClothesDao.getInstance().FindList(parent, name); dataTable.Columns.Add("numText"); foreach (DataRow dr in dataTable.Rows) { dr["numText"] = ProductClothesDao.getInstance().getNumString((int)(dr["Product.ID"])); } return(dataTable); }
public override DataTable getRecordsTable(int parentId, string name) { Category parent = null; if (parentId > 0) { parent = CategoryDao.getInstance().FindById(this.CategoryTableName, parentId); } DataTable dataTable = ProductClothesDao.getInstance().FindList(parent, name); return(dataTable); }
/// <summary> /// event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripButton3_Click(object sender, EventArgs e) { Product product = null; if (this.getProduct(out product) == false) { return; } if (openMode == 0) { ProductClothesDao.getInstance().Insert(product, this.pickValue_color.getListRight(), this.pickValue_size.getListRight()); MessageBox.Show("保存货品成功,在相应的类别目录下可以找到该货品!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (openMode == 1) { product.ID = productID; bool basicResult = ProductClothesDao.getInstance().UpdateBasicInfo(product); bool basicAttr = true; if (attributeChanged) { basicAttr = ProductClothesDao.getInstance().UpdateAttributes(productID, product, this.pickValue_color.getListRight(), this.pickValue_size.getListRight()); } if (basicResult && basicAttr) { MessageBox.Show("修改货品成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("该货品已被单据引用,无法修改颜色和尺码等属性!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } this.attributeChanged = false; this.invokeUpdateNotify(UpdateType.ProductUpdate); this.Close(); }
protected override void productEditingControl_valueSetted(object sender, LookupArg arg) { //File.AppendAllText("e:\\debug.txt", string.Format("value changed, thread:{0}\r\n", System.Threading.Thread.CurrentThread.ManagedThreadId)); DataGridViewLookupEditingControl control = (sender as DataGridViewLookupEditingControl); try { //File.AppendAllText("e:\\debug.txt", string.Format("value changed, dataGridView hash code={0}, dataGridView name={1}\r\n", control.EditingControlDataGridView.GetHashCode(), control.EditingControlDataGridView.Name)); if (control.EditingControlDataGridView.Rows.Count == 0 || control.EditingControlDataGridView.CurrentCell == null) { throw new Exception(); } //if(control.EditingControlDataGridView.CurrentCell.OwningColumn.Name == "product") if (!string.IsNullOrEmpty(arg.ArgName) && arg.ArgName == "Product") { int productID = (int)(arg.Value); int oldID = -1; int.TryParse((control.EditingControlDataGridView.Rows[control.EditingControlRowIndex].Cells["product"].Value).ToString(), out oldID); if (productID != oldID) { control.EditingControlDataGridView.Rows[control.EditingControlRowIndex].Cells["price"].Value = ProductClothesDao.getInstance().FindPriceByID(productID); DataGridViewLookupEditingControl lookup = sender as DataGridViewLookupEditingControl; this.setCellEnable(control.EditingControlDataGridView.Rows[control.EditingControlRowIndex].Cells["num"], true); control.EditingControlDataGridView.Rows[control.EditingControlRowIndex].Cells["num"].Value = new LookupArg("", ""); } } //not reasonal setSubTotalPrice(control.EditingControlRowIndex); setTotalPrice(); } catch (Exception ex) { //File.AppendAllText("e:\\debug.txt",string.Format("exception, dataGridView.Rows.Count={0}\r\n", this.dataGridView1.Rows.Count)); //File.AppendAllText("e:\\debug.txt", string.Format("exception, dataGridView hash code={0}, dataGridView name={1}\r\n", control.EditingControlDataGridView.GetHashCode(), control.EditingControlDataGridView.Name)); System.Threading.Thread.Sleep(0); } this.resetNeedSave(true); this.recordChanged = true; }
public override void delItems(int id) { ProductClothesDao.getInstance().Delete(id); }