private void editGrid1_CellEndEdit(object sender, string column_name, DataRow row) { if (isSelect) { return; } if (column_name == "item_subno") { if (string.IsNullOrEmpty(row[column_name].ToString())) { return; } IBLL.IPriceBLL pricebll = new BLL.PriceBLL(); IBLL.IItem itembll = new BLL.ItemBLL(); var sup_id = txt_sup.Text.Trim().Split('/')[0]; DataTable tb = itembll.GetLikeItem(sup_id, 1, row["item_subno"].ToString(), "0"); if (tb.Rows.Count > 1) { SelectRow(row, row["item_subno"].ToString()); } else { foreach (DataRow dr in tb.Rows) { Conv.CopyDataRow(row, dr); row["discount"] = "1"; row["in_price"] = pricebll.GetSupItemPrice(sup_id, dr["item_no"].ToString(), "0"); row["sub_amount"] = Helper.Conv.ToDecimal(row["order_qnty"]) * Helper.Conv.ToDecimal(row["in_price"]) * Helper.Conv.ToDecimal(row["discount"]); break; } if (tb.Rows.Count < 1) { row[column_name] = ""; } } if (!string.IsNullOrEmpty(this.editGrid1.DataSource.Rows[this.editGrid1.DataSource.Rows.Count - 1]["item_subno"].ToString())) { this.editGrid1.DataSource.Rows.Add(); } } else if (column_name == "in_price" || column_name == "order_qnty" || column_name == "discount") { row["sub_amount"] = Helper.Conv.ToDecimal(row["order_qnty"]) * Helper.Conv.ToDecimal(row["in_price"]) * Helper.Conv.ToDecimal(row["discount"]); editGrid1.Refresh(); } }
private void editGrid1_CellEndEdit(object sender, string column_name, DataRow row) { if (isSelect) { return; } if (column_name == "item_subno") { if (string.IsNullOrEmpty(row[column_name].ToString())) { return; } IBLL.IPriceBLL pricebll = new BLL.PriceBLL(); IBLL.IItem itembll = new BLL.ItemBLL(); var sup_id = this.txt_cust.Text.Trim().Split('/')[0]; DataTable tb = itembll.GetLikeItem(sup_id, 1, row["item_subno"].ToString(), "0"); if (tb.Rows.Count > 1) { SelectRow(row, row["item_subno"].ToString()); } else { foreach (DataRow dr in tb.Rows) { int index = 0; for (int i = 0; i < this.editGrid1.DataSource.Rows.Count; i++) { if (this.editGrid1.DataSource.Rows[i] == row) { index = i; } } var dgv_tb = this.editGrid1.DataSource.Copy(); dgv_tb.ImportRow(dr); var dgv_dr = dgv_tb.Rows[dgv_tb.Rows.Count - 1]; dgv_dr["real_price"] = pricebll.GetCustItemPrice(sup_id, dr["item_no"].ToString(), "0"); dgv_dr["sale_money"] = 0.00; Conv.CopyDataRow(this.editGrid1.DataSource, index, dgv_dr); break; } if (tb.Rows.Count < 1) { row[column_name] = ""; } } if (!string.IsNullOrEmpty(this.editGrid1.DataSource.Rows[this.editGrid1.DataSource.Rows.Count - 1]["item_subno"].ToString())) { this.editGrid1.DataSource.Rows.Add(); } } else if (column_name == "other3" && row["other3"].ToString() == "1") //赠送 { row["real_price"] = 0; row["sale_money"] = 0; editGrid1.Refresh(); } else if (column_name == "sale_qnty" || column_name == "real_price") { row["sale_money"] = Helper.Conv.ToDecimal(row["real_price"]) * Helper.Conv.ToDecimal(row["sale_qnty"]); editGrid1.Refresh(); } }