/// <summary> /// event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripButton_save_Click(object sender, EventArgs e) { ProductStainless product = null; if (this.getProduct(out product) == false) { return; } if (openMode == 0) { ProductStainlessDao.getInstance().Insert(product); MessageBox.Show("保存货品成功,在相应的类别目录下可以找到该货品!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (openMode == 1) { product.ID = productID; bool basicResult = ProductStainlessDao.getInstance().Update(product); if (basicResult) { MessageBox.Show("修改货品成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } this.invokeUpdateNotify(UpdateType.ProductUpdate); this.Close(); }
private void 全部数据清空ToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("数据将全部被清除,建议先备份数据文件后再清除,是否备份?", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { 导出数据文件ToolStripMenuItem_Click(null, null); } else if (result == DialogResult.No) { if (MessageBox.Show("现有数据将全部被清除,是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK) { return; } else { CustomerDao.getInstance().ClearAllArrear(); PayReceiptDao.getInstance().DeleteAll(); ProductStainlessCirculationDao.getInstance().DeleteAll(); SellProfitDao.getInstance().DeleteAll(); ProductStainlessDao.getInstance().ClearAllNumAndCost(); MessageBox.Show("删除清空数据成功,系统将自动关闭,请重新启动软件!", "提示", MessageBoxButtons.OK); this.Close(); } } }
protected override void statisticProduct() { itemsTable = ProductStainlessDao.getInstance().FindList(null, null, true); itemsTable.Columns.Add("purchase"); itemsTable.Columns.Add("purchaseBack"); itemsTable.Columns.Add("sell"); itemsTable.Columns.Add("sellBack"); foreach (DataRow dr in itemsTable.Rows) { double totalNum = 0; double sum = 0; int productID = (int)dr["ProductStainless.ID"]; this.getSum(this.dateTimePicker3.Value, this.dateTimePicker4.Value, 1, productID, 0, out totalNum, out sum); dr["purchase"] = totalNum == 0 && sum == 0 ? "" : string.Format("{0}/{1:0.00}", totalNum, sum); this.getSum(this.dateTimePicker3.Value, this.dateTimePicker4.Value, 2, productID, 0, out totalNum, out sum); dr["purchaseBack"] = totalNum == 0 && sum == 0 ? "" : string.Format("{0}/{1:0.00}", totalNum, sum); this.getSum(this.dateTimePicker3.Value, this.dateTimePicker4.Value, 3, productID, 0, out totalNum, out sum); dr["sell"] = totalNum == 0 && sum == 0 ? "" : string.Format("{0}/{1:0.00}", totalNum, sum); this.getSum(this.dateTimePicker3.Value, this.dateTimePicker4.Value, 4, productID, 0, out totalNum, out sum); dr["sellBack"] = totalNum == 0 && sum == 0 ? "" : string.Format("{0}/{1:0.00}", totalNum, sum); } }
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); //File.AppendAllText("e:\\debug.txt", string.Format("value changed, control hash code={0}, control name={1}\r\n", control.GetHashCode(), control.Name)); 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 == "ProductStainless") { int productID = (int)(arg.Value); int oldID = -1; int.TryParse((control.EditingControlDataGridView.Rows[control.EditingControlRowIndex].Cells["product"].Value).ToString(), out oldID); if (productID != oldID) { ProductStainless product = ProductStainlessDao.getInstance().FindByID(productID); //stone 临时关闭 control.EditingControlDataGridView.Rows[control.EditingControlRowIndex].Cells["serial"].Value = product.Serial; control.EditingControlDataGridView.Rows[control.EditingControlRowIndex].Cells["quantityPerPiece"].Value = product.QuantityPerPiece; control.EditingControlDataGridView.Rows[control.EditingControlRowIndex].Cells["unit"].Value = product.Unit; if (conf.type == ProductCirculation.CirculationType.sell || conf.type == ProductCirculation.CirculationType.sellBack) { //这里要加个.ToString(),可能自定义Cell的value类型不大一样 control.EditingControlDataGridView.Rows[control.EditingControlRowIndex].Cells["price"].Value = product.PriceSell.ToString(); } else { control.EditingControlDataGridView.Rows[control.EditingControlRowIndex].Cells["price"].Value = product.PricePurchase.ToString(); } } } //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 DataTable getRecordsTable(int parentId, string name) { Category parent = null; if (parentId > 0) { parent = CategoryDao.getInstance().FindById(this.CategoryTableName, parentId); } DataTable dataTable = ProductStainlessDao.getInstance().FindList(parent, name, true); return(dataTable); }
protected override DataTable getRecordsTable(int parentId, string searchName) { Category parent = null; if (parentId > 0) { parent = CategoryDao.getInstance().FindById(conf.CategoryTableName, parentId); } DataTable dataTable; if (this.openMode == 0) { dataTable = ProductStainlessDao.getInstance().FindList(parent, searchName, true); } else { dataTable = ProductStainlessDao.getInstance().FindList(parent, searchName, false); } return(dataTable); }
private void initProduct() { this.label4.Text = "编辑货品, ID:" + productID; ProductStainless product = ProductStainlessDao.getInstance().FindByID(productID); this.textBox_name.Text = product.Name; this.textBox_serial.Text = product.Serial; this.comboBoxTree_category.setSelectNode(product.CategoryID.ToString()); this.textBox_purchasePrice.Text = product.PricePurchase.ToString(); this.textBox_sellPrice.Text = product.PriceSell.ToString(); this.textBox_cost.Text = product.PriceCost.ToString(); this.textBox_quantityPerPiece.Text = product.QuantityPerPiece.ToString(); this.comboBox_unit.Text = product.Unit; this.textBox_libNum.Text = product.Num.ToString(); this.textBox_comment.Text = product.Comment; this.radioButton2.Checked = product.Disable; }
public override void delItems(int id) { ProductStainlessDao.getInstance().Delete(id); }
private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { receipt = purchaseBack = otherReceipt = 0; payed = sellBack = freights = otherPay = 0; payReceiptList = PayReceiptDao.getInstance().FindPayReceiptList(null, null, 4, null, -1, 1); circulationList = ProductStainlessCirculationDao.getInstance().FindProductCirculationList(1, 4, null, null, 4, null, -1); foreach (ProductCirculation cir in circulationList) { int type = cir.Type; if (type == 1) { payed += cir.ThisPayed; } else if (type == 2) { purchaseBack += cir.ThisPayed; } else if (type == 3) { receipt += cir.ThisPayed; } else if (type == 4) { sellBack += cir.ThisPayed; } freights += cir.Freight; } foreach (PayReceipt pr in payReceiptList) { PayReceipt.BillType type = pr.bill_type; switch (type) { case PayReceipt.BillType.BuyPay: payed += pr.thisPayed; break; case PayReceipt.BillType.BuyRefund: purchaseBack += pr.thisPayed; break; case PayReceipt.BillType.SellReceipt: receipt += pr.thisPayed; break; case PayReceipt.BillType.SellRefund: sellBack += pr.thisPayed; break; case PayReceipt.BillType.OtherPay: otherPay += pr.thisPayed; break; case PayReceipt.BillType.OtherReceipt: otherReceipt += pr.thisPayed; break; default: break; } } lib = 0; productDT = ProductStainlessDao.getInstance().FindList(null, null, true); foreach (DataRow dr in productDT.Rows) { double price; int num; bool positive; ValidateUtility.getInt(dr, "num", out num, out positive); ValidateUtility.getDouble(dr, "priceCost", out price); //这里如果直接取ProductStainless就不需要判断 if (price <= 0) { ValidateUtility.getDouble(dr, "pricePurchase", out price); } lib = lib + price * num; } needPay = needReceipt = 0; customerDT = CustomerDao.getInstance().FindList(null, null); foreach (DataRow dr in customerDT.Rows) { double arrear = 0; ValidateUtility.getDouble(dr, "arrear", out arrear); if (arrear > 0) { needPay += arrear; } else { needReceipt -= arrear; } } }
protected override void delItem(int id) { ProductStainlessDao.getInstance().Delete(id); }