private void reSetCurrentDt() { _currentDt.Columns.Add("Row"); _currentDt.Columns.Add("RECEIPT_RATE"); _currentDt.Columns.Add("RERECEIPT_RATE"); _currentDt.Columns.Add("ON_SCHEDULE_RECEIPT_RATE"); for (int i = 0; i <= _currentDt.Rows.Count - 1; i++) { _currentDt.Rows[i]["Row"] = i + 1; decimal purchase = CConvert.ToDecimal(_currentDt.Rows[i]["PURCHASE_QUANTITY"]); decimal receipt = CConvert.ToDecimal(_currentDt.Rows[i]["RECEIPT_QUANTITY"]); decimal rereceipt = CConvert.ToDecimal(_currentDt.Rows[i]["RERECEIPT_QUANTITY"]); decimal ontimereceipt = CConvert.ToDecimal(_currentDt.Rows[i]["ON_SCHEDULE_RECEIPT_QUANTITY"]); _currentDt.Rows[i]["RECEIPT_RATE"] = string.Format("{0:F2}", ((decimal)((receipt / purchase) * 100))) + "%"; if ((rereceipt + receipt) > 0) { _currentDt.Rows[i]["RERECEIPT_RATE"] = string.Format("{0:F2}", ((decimal)((rereceipt / (receipt + rereceipt)) * 100))) + "%"; } else { _currentDt.Rows[i]["RERECEIPT_RATE"] = "0%"; } _currentDt.Rows[i]["ON_SCHEDULE_RECEIPT_RATE"] = string.Format("{0:F2}", ((decimal)((ontimereceipt / purchase) * 100))) + "%"; } }
private void btnSave_Click(object sender, EventArgs e) { if (CheckInput()) { BllHistoryStockTable HSTable = new BllHistoryStockTable(); BllHistoryStockLineTable HSLTable = null; HSTable.SLIP_NUMBER = txtSlipNumber.Text.Trim(); HSTable.SLIP_DATE = txtSlipDate.Value; HSTable.WAREHOUSE_CODE = txtWarehouseCode.Text.Trim(); HSTable.CREATE_USER = _userInfo.CODE; HSTable.LAST_UPDATE_USER = _userInfo.CODE; foreach (DataGridViewRow row in dgvData.Rows) { if (row.Cells["PRODUCT_CODE"].Value != null) { HSLTable = new BllHistoryStockLineTable(); HSLTable.SLIP_NUMBER = txtSlipNumber.Text.Trim(); HSLTable.LINE_NUMBER = row.Index + 1; HSLTable.PRODUCT_CODE = row.Cells["PRODUCT_CODE"].Value.ToString(); HSLTable.QUANTITY = CConvert.ToDecimal(row.Cells["SANCTION_NUMBER"].Value.ToString()); HSLTable.UNIT_CODE = row.Cells["UNIT_CODE"].Value.ToString(); HSLTable.REASON_CODE = row.Cells["REASON"].Value.ToString(); if (HSLTable.SLIP_NUMBER != null) { HSTable.AddItem(HSLTable); } } } int result = 0; try { bool b = true; result = bStock.AddHistory(HSTable); if (result <= 0) { b = false; string errorLog = "保存失败,请重试或与管理员联系."; MessageBox.Show(errorLog, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } if (b && dgvData.Rows.Count > 0) { dgvData.Rows.Clear(); initSlipNumber(); txtWarehouseCode.Text = ""; txtWarehouseName.Text = ""; MessageBox.Show("保存成功", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("保存失败,系统错误,请与管理员联系.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); Logger.Error("新建订单保存失败!", ex); } } }
private bool CheckInput() { if (string.IsNullOrEmpty(txtSupplierCode.Text.Trim())) { MessageBox.Show("客户编号不能为空。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); txtSupplierCode.Focus(); return(false); } else if (dgvData.Rows.Count <= 0) { MessageBox.Show("明细行数必须大于零。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); btnAddRow.Focus(); return(false); } foreach (DataGridViewRow dgvr in dgvData.Rows) { string orderSlipNumber = CConvert.ToString(dgvr.Cells["PURCHASE_ORDER_SLIP_NUMBER"].Value).Trim(); if (orderSlipNumber == "") { MessageBox.Show("明细行订单编号不能为空。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); dgvr.Cells["PURCHASE_ORDER_SLIP_NUMBER"].Selected = true; return(false); } decimal amount = CConvert.ToDecimal(dgvr.Cells["AMOUNT"].Value); if (amount <= 0) { MessageBox.Show("明细行金额必须大于零。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); dgvr.Cells["AMOUNT"].Selected = true; return(false); } } return(true); }
private void Search() { string strWhere = GetConduction(); DataTable dt = bProductionPlanSearch.GetProductionPlan(strWhere).Tables[0]; if (dt.Rows.Count < 1) { txtSlipNumber.Clear(); txtOrder.Clear(); dgvData.DataSource = dt; MessageBox.Show("查询的信息不存在!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { dgvData.DataSource = dt; } decimal weight = 0; foreach (DataRow row in dt.Rows) { weight += CConvert.ToDecimal(row["WEIGHT"].ToString()); } txtTotal.Text = weight.ToString(); }
private void btnAddProductionProcess_Click(object sender, EventArgs e) { FrmMasterSearch frm = new FrmMasterSearch("PRODUCTION_PROCESS", ""); if (frm.ShowDialog(this) == DialogResult.OK) { string strWhere = " CODE = " + "'" + frm.BaseMasterTable.Code + "'"; DataSet ds = BProductionProcess.GetList(strWhere); string departmentcode = ds.Tables[0].Rows[0]["DEPARTMENT_CODE"].ToString().Trim(); string departmentname = ds.Tables[0].Rows[0]["DEPARTMENT_NAME"].ToString().Trim(); decimal productioncycle = CConvert.ToDecimal(ds.Tables[0].Rows[0]["PRODUCTION_CYCLE"].ToString().Trim()); if (dgvData.Rows.Count > 0) { int dgvrow = dgvData.Rows.Count - 1; DateTime StartDate = CConvert.ToDateTime(dgvData.Rows[dgvrow].Cells["END_DATE"].Value.ToString()); DateTime EndDate = StartDate.AddDays(CConvert.ToDouble(productioncycle) + 0D); object[] rows = { "", frm.BaseMasterTable.Code, frm.BaseMasterTable.Name, departmentcode, departmentname, StartDate, EndDate, "", productioncycle }; dgvData.Rows.Add(rows); } else { DateTime EndDate = CConvert.ToDateTime(txtSlipDateFrom.Text).AddDays(CConvert.ToDouble(productioncycle) + 0D); object[] rows = { "", frm.BaseMasterTable.Code, frm.BaseMasterTable.Name, departmentcode, departmentname, txtSlipDateFrom.Text, EndDate, "", productioncycle }; dgvData.Rows.Add(rows); } } frm.Dispose(); }
/// <summary> /// 获得未含税金额 /// </summary> /// <param name="totalAmount"></param> /// <param name="taxRate"></param> /// <returns></returns> private decimal GetAmountWithoutTax(object totalAmount, object taxRate) { decimal a = CConvert.ToDecimal(totalAmount); decimal r = CConvert.ToDecimal(taxRate); return(Math.Round(a / (1 + r), 2)); }
/// <summary> /// 获得查询条件 /// </summary> private string GetConduction() { StringBuilder sb = new StringBuilder(); sb.AppendFormat(" STATUS_FLAG <> {0}", CConstant.DELETE); if (txtCode.Text.Trim() != "") { sb.AppendFormat(" and CODE like '{0}%'", txtCode.Text.Trim()); } if (txtName.Text.Trim() != "") { sb.AppendFormat(" and NAME like '{0}%'", txtName.Text.Trim()); } if (txtGroupCode.Text.Trim() != "") { sb.AppendFormat(" and GROUP_CODE like '{0}%'", txtGroupCode.Text.Trim()); } if (txtGroupName.Text.Trim() != "") { sb.AppendFormat(" and GROUP_NAME like '{0}%'", txtGroupName.Text.Trim()); } if (!string.IsNullOrEmpty(CConvert.ToString(cboDistinction.SelectedValue))) { sb.AppendFormat(" and DISTINCTION = '{0}'", CConvert.ToDecimal(cboDistinction.SelectedValue)); } return(sb.ToString()); }
private bool saveCheck() { string strErrlog = null; foreach (DataGridViewRow row in dgvData.Rows) { if (row.Cells["No"].Value == null || "".Equals(row.Cells["No"].Value.ToString())) { break; } // 预付款金额 decimal depositAmount = CConvert.ToDecimal(CConvert.ToString(row.Cells["DEPOSIT_AMOUNT"].Value)); //其他金额 decimal otherAmount = CConvert.ToDecimal(CConvert.ToString(row.Cells["OTHER_AMOUNT"].Value)); //收款总金额 decimal totalAmount = depositAmount + otherAmount; if (totalAmount == 0) { strErrlog = "第" + row.Cells["No"].Value.ToString() + "行请输入付款金额!\r\n"; } } if (!string.IsNullOrEmpty(strErrlog)) { MessageBox.Show(strErrlog); return(false); } return(true); }
/// <summary> /// 总金额计算 /// </summary> private void CalculateAmount() { decimal IncludedTaxAmount = 0; //decimal WithoutTaxAmount = 0; foreach (DataGridViewRow dr in dgvData.Rows) { if (txtdiscountrate.Text.Trim() == "") { IncludedTaxAmount += CConvert.ToDecimal(dr.Cells["AMOUNT"].Value); } else { IncludedTaxAmount += CConvert.ToDecimal(dr.Cells["AMOUNT"].Value) * (100 - decimal.Parse(txtdiscountrate.Text)) / 100; } } //decimal taxation = CConvert.ToDecimal(cboTax.Text.Replace("%", "")); //WithoutTaxAmount = WithoutAmount(IncludedTaxAmount, taxation / 100); //txtAmountIncludedTax.Text = string.Format("{0:N2}", Math.Round(IncludedTaxAmount, 2)); //txtTotal.Text = string.Format("{0:N2}", Math.Round(WithoutTaxAmount, 2)); txtTotal.Text = string.Format("{0:N2}", Math.Round(IncludedTaxAmount, 2)); // txtTaxAmount.Text = string.Format("{0:N2}", Math.Round(IncludedTaxAmount - WithoutTaxAmount, 2)); //txtAmountWithoutTax.Text = Math.Round(IncludedTaxAmount - taxAmount, 2).ToString(); }
private bool CheckInput() { string strErrorlog = null; foreach (DataGridViewRow row in dgvData.Rows) { if (CConvert.ToDecimal(row.Cells["QUANTITY"].Value) == 0) { strErrorlog += "第" + (row.Index + 1) + "行" + "库存数不能为0!\r\n"; } if (CConvert.ToDecimal(row.Cells["TRANSFER_QUANTITY"].Value) <= 0 || row.Cells["TRANSFER_QUANTITY"] == null) { strErrorlog += "第" + (row.Index + 1) + "行" + "调拨数量不能为空或输入错误!\r\n"; } if (CConvert.ToDecimal(row.Cells["QUANTITY"].Value) < CConvert.ToDecimal(row.Cells["TRANSFER_QUANTITY"].Value)) { strErrorlog += "第" + (row.Index + 1) + "行" + "库存数量不能小于调拨数量!\r\n"; row.Cells["TRANSFER_QUANTITY"].Value = 0; } } if (strErrorlog != null || "".Equals(strErrorlog)) { MessageBox.Show(strErrorlog, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } return(true); }
//获得在库数 public decimal GetStock(string warehouse, string product) { StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT QUANTITY FROM BASE_STOCK"); strSql.Append(" where WAREHOUSE_CODE=@WAREHOUSE_CODE and PRODUCT_CODE=@PRODUCT_CODE "); strSql.AppendFormat("and STATUS_FLAG <>{0}", CConstant.DELETE); SqlParameter[] stockParam = { new SqlParameter("@WAREHOUSE_CODE", SqlDbType.VarChar, 20), new SqlParameter("@PRODUCT_CODE", SqlDbType.VarChar, 20) }; stockParam[0].Value = warehouse; stockParam[1].Value = product; object obj = DbHelperSQL.GetSingle(strSql.ToString(), stockParam); if (obj == null) { return(0); } else { return(CConvert.ToDecimal(obj)); } }
/// <summary> /// 数据保存前明细数据验证 /// </summary> private bool CheckLineInput() { if (dgvData.Rows.Count == 0) { MessageBox.Show("明细数不能为空。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } foreach (DataGridViewRow row in dgvData.Rows) { if (CConvert.ToString(row.Cells["PRODUCT_CODE"].Value) == "") { MessageBox.Show("商品编号不能为空。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } else if (CConvert.ToString(row.Cells["QUANTITY"].Value) == "") { MessageBox.Show("采购数量不能为空。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } else if (CConvert.ToDecimal(row.Cells["QUANTITY"].Value) == 0) { MessageBox.Show("采购数量不能为零。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } else if (CConvert.ToString(row.Cells["PRICE"].Value) == "") { MessageBox.Show("采购单价不能为空。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } } return(true); }
/// <summary> /// 数字列求合 /// </summary> private decimal addDecimal(object first, object two) { decimal f = CConvert.ToDecimal(first); decimal t = CConvert.ToDecimal(two); return(f + t); }
/// <summary> /// 引当数量的取得 /// </summary> public decimal GetAlloationQuantity(string orderSlipNumber, string warehouseCode, string productCode) { decimal alloationQuantity = 0; StringBuilder strSql = new StringBuilder(); strSql.Append(" SELECT ISNULL(SUM(QUANTITY),0) FROM BLL_ALLOATION "); strSql.Append(" where WAREHOUSE_CODE=@WAREHOUSE_CODE and PRODUCT_CODE = @PRODUCT_CODE and ORDER_SLIP_NUMBER<>@ORDER_SLIP_NUMBER"); strSql.AppendFormat(" and STATUS_FLAG <> {0} and STATUS_FLAG <> {1} ", CConstant.DELETE, CConstant.ALLOATION_SHIPMENT); SqlParameter[] parameters = { new SqlParameter("@WAREHOUSE_CODE", SqlDbType.VarChar, 20), new SqlParameter("@PRODUCT_CODE", SqlDbType.VarChar, 20), new SqlParameter("@ORDER_SLIP_NUMBER", SqlDbType.VarChar, 20) }; parameters[0].Value = warehouseCode; parameters[1].Value = productCode; parameters[2].Value = orderSlipNumber; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj != null) { alloationQuantity = CConvert.ToDecimal(obj); } return(alloationQuantity); }
/// <summary> /// 得到一个对象实体 /// </summary> public CZZD.ERP.Model.BaseSafetyStockTable GetModel(string WAREHOUSE_CODE, string PRODUCT_CODE) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 WAREHOUSE_CODE,PRODUCT_CODE,UNIT_CODE,SAFETY_STOCK,STATUS_FLAG,CREATE_USER,CREATE_DATE_TIME,LAST_UPDATE_USER,LAST_UPDATE_TIME,WAREHOUSE_NAME,PRODUCT_NAME,UNIT_NAME,MAX_QUANTITY,MIN_PURCHASE_QUANTITY from base_safety_stock_view "); strSql.Append(" where WAREHOUSE_CODE=@WAREHOUSE_CODE and PRODUCT_CODE=@PRODUCT_CODE "); strSql.AppendFormat(" and STATUS_FLAG <> {0}", CConstant.DELETE); SqlParameter[] parameters = { new SqlParameter("@WAREHOUSE_CODE", SqlDbType.VarChar, 50), new SqlParameter("@PRODUCT_CODE", SqlDbType.VarChar, 50) }; parameters[0].Value = WAREHOUSE_CODE; parameters[1].Value = PRODUCT_CODE; CZZD.ERP.Model.BaseSafetyStockTable model = new CZZD.ERP.Model.BaseSafetyStockTable(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { model.WAREHOUSE_CODE = ds.Tables[0].Rows[0]["WAREHOUSE_CODE"].ToString(); model.PRODUCT_CODE = ds.Tables[0].Rows[0]["PRODUCT_CODE"].ToString(); model.UNIT_CODE = ds.Tables[0].Rows[0]["UNIT_CODE"].ToString(); if (ds.Tables[0].Rows[0]["SAFETY_STOCK"].ToString() != "") { model.SAFETY_STOCK = decimal.Parse(ds.Tables[0].Rows[0]["SAFETY_STOCK"].ToString()); } if (ds.Tables[0].Rows[0]["STATUS_FLAG"].ToString() != "") { model.STATUS_FLAG = int.Parse(ds.Tables[0].Rows[0]["STATUS_FLAG"].ToString()); } model.CREATE_USER = ds.Tables[0].Rows[0]["CREATE_USER"].ToString(); if (ds.Tables[0].Rows[0]["CREATE_DATE_TIME"].ToString() != "") { model.CREATE_DATE_TIME = DateTime.Parse(ds.Tables[0].Rows[0]["CREATE_DATE_TIME"].ToString()); } model.LAST_UPDATE_USER = ds.Tables[0].Rows[0]["LAST_UPDATE_USER"].ToString(); if (ds.Tables[0].Rows[0]["LAST_UPDATE_TIME"].ToString() != "") { model.LAST_UPDATE_TIME = DateTime.Parse(ds.Tables[0].Rows[0]["LAST_UPDATE_TIME"].ToString()); } model.WAREHOUSE_NAME = ds.Tables[0].Rows[0]["WAREHOUSE_NAME"].ToString(); model.PRODUCT_NAME = ds.Tables[0].Rows[0]["PRODUCT_NAME"].ToString(); model.UNIT_NAME = ds.Tables[0].Rows[0]["UNIT_NAME"].ToString(); if (ds.Tables[0].Rows[0]["MAX_QUANTITY"].ToString() != "") { model.MAX_QUANTITY = CConvert.ToDecimal(ds.Tables[0].Rows[0]["MAX_QUANTITY"]); } if (ds.Tables[0].Rows[0]["MIN_PURCHASE_QUANTITY"].ToString() != "") { model.MIN_PURCHASE_QUANTITY = CConvert.ToDecimal(ds.Tables[0].Rows[0]["MIN_PURCHASE_QUANTITY"]); } return(model); } else { return(null); } }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { if (CheckInput()) { if (_currentProductTable == null) { _currentProductTable = new BaseProductTable(); } _currentProductTable.CODE = txtCode.Text.Trim(); _currentProductTable.NAME = txtName.Text.Trim(); _currentProductTable.SPEC = txtSpec.Text.Trim(); _currentProductTable.GROUP_CODE = txtGroupCode.Text.Trim(); _currentProductTable.BASIC_UNIT_CODE = txtUnitCode.Text.Trim(); _currentProductTable.SALES_PRICE = Convert.ToDecimal(txtPrice.Text.Trim()); _currentProductTable.LAST_UPDATE_USER = _userInfo.CODE; _currentProductTable.PURCHASE_PRICE = CConvert.ToDecimal(txtPurchase_Price.Text.Trim()); _currentProductTable.SELL_LOCATION = CConstant.PRODUCT_SELL_CHINA; _currentProductTable.PACKAGE_MODE = CConstant.PRODUCT_PACKAGE_ALONT; _currentProductTable.SAFETY_STOCK = CConvert.ToDecimal(txtSafetyStock.Text.Trim()); _currentProductTable.PRODUCT_FLAG = CConstant.PRODUCT_FLAG_PARTS; try { bool ret = false; if (bProduct.Exists(txtCode.Text.Trim())) { ret = bProduct.Update(_currentProductTable); } else { _currentProductTable.CREATE_USER = _userInfo.CODE; ret = bProduct.Add(_currentProductTable); } if (ret) { result = DialogResult.OK; if ("btnSaveAndNew".Equals(((Button)sender).Name)) { ClearAll(); } else { this.Close(); } } else { MessageBox.Show("保存失败,请重试或与系统管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show("保存失败,请重试或与系统管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); Logger.Error("原料保存失败。", ex); return; } } }
private void btnSave_Click(object sender, EventArgs e) { if (CheckInput()) { BllTransferReceiptTable TRTable = new BllTransferReceiptTable(); BllTransferReceiptLineTable TRLTable = null; TRTable.SLIP_NUMBER = txtSlipNumber.Text.Trim(); TRTable.DEPARTUAL_WAREHOUSE_CODE = txtDepartualCode.Text.Trim(); TRTable.ARRIVAL_WAREHOUSE_CODE = txtArrivalCode.Text.Trim(); TRTable.SLIP_DATE = txtSlipDate.Value; TRTable.CREATE_USER = _userInfo.CODE; TRTable.LAST_UPDATE_USER = _userInfo.CODE; foreach (DataGridViewRow row in dgvData.Rows) { TRLTable = new BllTransferReceiptLineTable(); TRLTable.SLIP_NUMBER = txtSlipNumber.Text.Trim(); TRLTable.LINE_NUMBER = row.Index + 1; TRLTable.PRODUCT_CODE = row.Cells["PRODUCT_CODE"].Value.ToString(); TRLTable.QUANTITY = CConvert.ToDecimal(row.Cells["TRANSFER_QUANTITY"].Value); TRLTable.UNIT_CODE = row.Cells["UNIT_CODE"].Value.ToString(); if (TRLTable.SLIP_NUMBER != null) { TRTable.AddItem(TRLTable); } } int result = 0; try { result = bTransfer.Add(TRTable); if (result <= 0) { string errorLog = "保存失败,请重试或与管理员联系."; MessageBox.Show(errorLog, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (dgvData.Rows.Count > 0) { dgvData.Rows.Clear(); initSlipNumber(); txtDepartualCode.Text = ""; txtDepartualName.Text = ""; txtArrivalCode.Text = ""; txtArrivalName.Text = ""; txtSlipDate.Value = DateTime.Now; MessageBox.Show("保存成功", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("保存失败,系统错误,请与管理员联系.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); Logger.Error("仓库调拨失败!", ex); } } }
private void init() { BaseProductTable product = null; DataSet ds = bPurchaseOrder.GetList(strWhere); int i = 1; DataRow row = null; foreach (DataRow dr in ds.Tables[0].Rows) { row = dt.NewRow(); row["NO"] = i++; row["SLIP_NUMBER"] = dr["SLIP_NUMBER"]; string code = CConvert.ToString(dr["PRODUCT_CODE"]); product = new BProduct().GetModel(code); row["PRODUCT_CODE"] = dr["PRODUCT_CODE"]; row["PRODUCT_NAME"] = dr["PRODUCT_NAME"]; if (product == null) { product = new BaseProductTable(); } row["SPEC"] = product.SPEC; row["SUPPLIER_NAME"] = dr["SUPPLIER_NAME"]; row["QUANTITY"] = (int)CConvert.ToDecimal(dr["QUANTITY"]); row["PRICE"] = dr["PRICE"]; row["AMOUNT"] = dr["AMOUNT_INCLUDED_TAX"]; row["SLIP_DATE"] = CConvert.ToDateTime(dr["SLIP_DATE"]).ToString("yyyy-MM-dd"); row["DUE_DATE"] = CConvert.ToDateTime(dr["DUE_DATE"]).ToString("yyyy-MM-dd"); DateTime now = CConvert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); DateTime due = CConvert.ToDateTime(CConvert.ToDateTime(dr["DUE_DATE"]).ToString("yyyy-MM-dd")); if (now > due) { TimeSpan ts = now - due; row["DUE_STATUS"] = "超过期限" + ts.TotalDays + "天"; } else { row["DUE_STATUS"] = "未到时间"; } getReceipt(CConvert.ToString(dr["SLIP_NUMBER"])); if (Receipt == CConstant.UN_RECEIPT) { row["DELIVERY_STATUS"] = "未入库"; } else if (Receipt == CConstant.COMPLETE_RECEIPT) { row["DELIVERY_STATUS"] = "入库完了"; } else if (Receipt == CConstant.PART_RECEIPT) { row["DELIVERY_STATUS"] = "入库一部分"; } row["ACTUAL_AMOUNT"] = bPurchaseOrder.GetReceiptActualQuantity(CConvert.ToString(dr["SLIP_NUMBER"]), CConvert.ToString(dr["PRODUCT_CODE"])); total += CConvert.ToDecimal(dr["AMOUNT_INCLUDED_TAX"]); dt.Rows.Add(row); } }
///<summary> ///根据时间获得汇率 ///</summary> public Decimal GetExchange(DateTime dateTime, string FromCurrencyCode, string ToCurrencyCode) { StringBuilder sb = new StringBuilder(); sb.Append(" SELECT EXCHANGE_RATE FROM BASE_EXCHANGE "); sb.AppendFormat(" WHERE EXCHANGE_DATE='{0}'AND FROM_CURRENCY_CODE='{1}' AND TO_CURRENCY_CODE='{2}' AND STATUS_FLAG<>{3}", dateTime, FromCurrencyCode, ToCurrencyCode, CConstant.DELETE_STATUS); return(CConvert.ToDecimal(DbHelperSQL.GetSingle(sb.ToString()))); }
public decimal GetTotalDeposit(string supplierCode) { StringBuilder strSql = new StringBuilder(); strSql.Append(" SELECT SUM(DEPOSIT_AMOUNT) FROM BLL_DEPOSIT_AMOUNT_VIEW"); if (!string.IsNullOrEmpty(supplierCode)) { strSql.AppendFormat(" where SUPPLIER_CODE = '{0}'", supplierCode); } return(CConvert.ToDecimal(DbHelperSQL.GetSingle(strSql.ToString()))); }
/// <summary> /// 数据查询,绑定 /// </summary> private void BindData(int currentPage) { string strWhere = GetConduction(); DataSet ds = bProductBuild.GetBilldList(strWhere, "", (currentPage - 1) * PageSize + 1, currentPage * PageSize); dgvData.Rows.Clear(); foreach (DataRow rows in ds.Tables[0].Rows) { int currentRowIndex = dgvData.Rows.Add(1); DataGridViewRow row = dgvData.Rows[currentRowIndex]; row.Cells[1].Selected = false; row.Cells["No"].Value = rows["Row"]; row.Cells["PARTS_CODE"].Value = rows["PRODUCT_PART_CODE"]; row.Cells["MIN_QUANTITY"].Value = rows["QUANTITY"]; row.Cells["PARTS_NAME"].Value = rows["PRODUCT_PART_NAME"]; row.Cells["SPEC"].Value = rows["SPEC"]; row.Cells["UNIT_CODE"].Value = rows["UNIT_CODE"]; row.Cells["UNIT_NAME"].Value = rows["UNIT_NAME"]; //BAlloation bAlloation = new BAlloation(); decimal alloationQuantity = bAlloation.GetAlloationQuantity(txtWarehouse.Text.Trim(), CConvert.ToString(rows["PRODUCT_PART_CODE"])); BaseStockTable stock = new BaseStockTable(); stock = bPurchaseOrder.GetStockModel(txtWarehouse.Text.Trim(), CConvert.ToString(rows["PRODUCT_PART_CODE"])); row.Cells["NO_ALLOATION"].Value = stock.QUANTITY - alloationQuantity; row.Cells["PURCHASE_QUANTITY"].Value = CConvert.ToDecimal(rows["QUANTITY"]) * CConvert.ToDecimal(txtQuantity.Text.Trim()); if (CConvert.ToDecimal(row.Cells["NO_ALLOATION"].Value) >= CConvert.ToDecimal(row.Cells["PURCHASE_QUANTITY"].Value)) { row.Cells["STATUE_FLAG"].Value = "OK"; } else { row.Cells["STATUE_FLAG"].Value = "NG"; } double p = Convert.ToDouble(CConvert.ToDecimal(row.Cells["NO_ALLOATION"].Value) / CConvert.ToDecimal(row.Cells["MIN_QUANTITY"].Value)); int old = (int)Math.Floor(p); if (CConvert.ToInt32(rows["Row"]) == 1) { possible = old; } else if (possible >= old) { possible = old; } } if (ds.Tables[0].Rows.Count < PageSize * currentPage) { dgvData.Rows.Add(PageSize - ds.Tables[0].Rows.Count); } }
private void dgvData_CellValidated(object sender, DataGridViewCellEventArgs e) { try { DataGridViewRow dgvr = dgvData.Rows[e.RowIndex]; decimal UN_PAYMENT_AMOUNT = CConvert.ToDecimal(dgvr.Cells["UN_PAYMENT_AMOUNT"].Value); if (e.ColumnIndex == dgvData.Columns["DEPOSIT_AMOUNT"].Index) { if (CConvert.ToDecimal(dgvr.Cells["DEPOSIT_AMOUNT"].Value) <= UN_PAYMENT_AMOUNT && (CConvert.ToDecimal(dgvr.Cells["DEPOSIT_AMOUNT"].Value) + CConvert.ToDecimal(dgvr.Cells["OTHER_AMOUNT"].Value)) <= UN_PAYMENT_AMOUNT) { Calculate(); } else { MessageBox.Show("预付款金额不能大于未付金额,\r\n或预付款金额与付款金额之和不能大于未付金额", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); dgvr.Cells["DEPOSIT_AMOUNT"].Value = "0"; dgvr.Cells["DEPOSIT_AMOUNT"].Selected = true; } } else if (e.ColumnIndex == dgvData.Columns["OTHER_AMOUNT"].Index) { if (CConvert.ToDecimal(dgvr.Cells["OTHER_AMOUNT"].Value) <= UN_PAYMENT_AMOUNT && (CConvert.ToDecimal(dgvr.Cells["DEPOSIT_AMOUNT"].Value) + CConvert.ToDecimal(dgvr.Cells["OTHER_AMOUNT"].Value)) <= UN_PAYMENT_AMOUNT) { Calculate(); } else { MessageBox.Show("付款金额不能大于未付金额,\r\n或预付款金额与付款金额之和不能大于未付金额", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); dgvr.Cells["OTHER_AMOUNT"].Value = "0"; dgvr.Cells["OTHER_AMOUNT"].Selected = true; } } else if (e.ColumnIndex == dgvData.Columns["SLIP_DATE"].Index) { string slipDate = CConvert.ToString(dgvr.Cells["SLIP_DATE"].Value); if (slipDate != "") { DateTime dTime = DateTime.Now; try { dTime = DateTime.Parse(slipDate); } catch { MessageBox.Show("请输入正确的付款日期。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } dgvr.Cells["SLIP_DATE"].Value = dTime.ToString("yyyy-MM-dd"); } } } catch { } }
private void Calculate() { decimal totalAmount = 0; foreach (DataGridViewRow row in dgvData.Rows) { decimal depositAmount = CConvert.ToDecimal(CConvert.ToString(row.Cells["DEPOSIT_AMOUNT"].Value)); decimal otherAmount = CConvert.ToDecimal(CConvert.ToString(row.Cells["OTHER_AMOUNT"].Value)); totalAmount = totalAmount + depositAmount + otherAmount; } txtTotalNoPayment.Text = totalAmount.ToString(); }
/// <summary> /// /// </summary> private void dgvData_CellValidated(object sender, DataGridViewCellEventArgs e) { try { DataGridViewRow dr = dgvData.Rows[e.RowIndex]; if (e.ColumnIndex == dgvData.Columns["PURCHASE_ORDER_SLIP_NUMBER"].Index) { string purchaseOrderSlipNumber = CConvert.ToString(dr.Cells["PURCHASE_ORDER_SLIP_NUMBER"].Value).Trim(); string no = CConvert.ToString(dr.Cells["NO"].Value).Trim(); if (purchaseOrderSlipNumber != "") { BllPurchaseOrderTable purchaseOrderTable = bPurchaseOrder.GetModel(purchaseOrderSlipNumber); if (purchaseOrderTable != null) { if (!IsExist(purchaseOrderSlipNumber, no)) { dr.Cells["PURCHASE_ORDER_SLIP_NUMBER"].Value = purchaseOrderTable.SLIP_NUMBER; dr.Cells["PURCHASE_ORDER_SLIP_DATE"].Value = CConvert.ToDateTime(purchaseOrderTable.SLIP_DATE).ToString("yyyy-MM-dd"); dr.Cells["TOTAL_AMOUNT"].Value = purchaseOrderTable.TOTAL_AMOUNT; dr.Cells["ARR_AMOUNT"].Value = bDepositArr.GetArrAmount(purchaseOrderTable.SLIP_NUMBER); } } else { MessageBox.Show("订单编号不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); dr.Cells["PURCHASE_ORDER_SLIP_NUMBER"].Value = ""; dr.Cells["PURCHASE_ORDER_SLIP_DATE"].Value = ""; dr.Cells["TOTAL_AMOUNT"].Value = ""; dr.Cells["ARR_AMOUNT"].Value = "0"; dr.Cells["AMOUNT"].Value = ""; } } } else if (e.ColumnIndex == dgvData.Columns["AMOUNT"].Index) { string amount = CConvert.ToString(dr.Cells["AMOUNT"].Value); if (amount == "") { dr.Cells["AMOUNT"].Value = 0; } else { dr.Cells["AMOUNT"].Value = CConvert.ToDecimal(amount); } } } catch (Exception ex) { Logger.Error("CellValidated error!", ex); } }
private void initDta() { BllReReceiptTable RRTable = bReceipt.GetReModel(_slip_number); if (RRTable != null) { try { SlipDate.Value = CConvert.ToDateTime(RRTable.SLIP_DATE); txtSupplierCode.Text = RRTable.SUPPLIER_CODE; if (bCommon.GetBaseMaster("SUPPLIER", RRTable.SUPPLIER_CODE) != null) { txtSupplierName.Text = bCommon.GetBaseMaster("SUPPLIER", RRTable.SUPPLIER_CODE).Name; } txtPurchaseNumber.Text = RRTable.PO_SLIP_NUMBER; foreach (DataRow dr in CCacheData.Taxation.Rows) { if (CConvert.ToDecimal(dr["TAX_RATE"]) == CConvert.ToDecimal(RRTable.TAX_RATE) * 100) { this.cboTax.SelectedValue = dr["CODE"]; break; } } cboReturn.SelectedValue = RRTable.RERECEIPT_FLAG; foreach (BllReReceiptLineTable RRLTable in RRTable.Items) { int currentRowIndex = dgvData.Rows.Add(1); DataGridViewRow row = dgvData.Rows[currentRowIndex]; row.Cells[1].Selected = false; row.Cells["NO"].Value = RRLTable.LINE_NUMBER; row.Cells["PRODUCT_CODE"].Value = RRLTable.PRODUCT_CODE; BaseProductTable product = bProduct.GetModel(RRLTable.PRODUCT_CODE); if (product != null) { row.Cells["NAME"].Value = product.NAME; row.Cells["SPEC"].Value = product.SPEC + " " + product.MODEL_NUMBER; } row.Cells["QUANTITY"].Value = RRLTable.QUANTITY; if (bCommon.GetBaseMaster("UNIT", RRLTable.UNIT_CODE) != null) { row.Cells["UNIT_NAME"].Value = bCommon.GetBaseMaster("UNIT", RRLTable.UNIT_CODE).Name; } row.Cells["PRICE"].Value = RRLTable.PRICE; row.Cells["AMOUNT"].Value = RRLTable.PRICE * RRLTable.QUANTITY; row.Cells["AMOUNT_INCLUDED_TAX"].Value = RRLTable.PRICE * RRLTable.QUANTITY * (1 + RRTable.TAX_RATE); row.Cells["MEMO"].Value = RRLTable.MEMO; } } catch (Exception ex) { } } }
/// <summary> /// /// </summary> private void btnPrint_Click(object sender, EventArgs e) { _currentDt = bOrderHeader.GetPrintList(_currentConduction).Tables[0]; for (int i = 0; i < _currentDt.Rows.Count; i++) { #region 引当 if (CConstant.ALLOATION_COMPLETE.Equals(_currentDt.Rows[i]["ALLOATION_FLAG"])) { _currentDt.Rows[i]["ALLOATION_NAME"] = "完了"; } else if (CConstant.ALLOATION_PART.Equals(_currentDt.Rows[i]["ALLOATION_FLAG"])) { _currentDt.Rows[i]["ALLOATION_NAME"] = "欠品"; } else { _currentDt.Rows[i]["ALLOATION_NAME"] = "未引当"; } #endregion #region 出库 if (CConvert.ToDecimal(_currentDt.Rows[i]["SHIPMENT_QUANTITY"]) == 0) { _currentDt.Rows[i]["SHIPMENT_NAME"] = "未出库"; } else if (CConvert.ToDecimal(_currentDt.Rows[i]["QUANTITY"]) != CConvert.ToDecimal(_currentDt.Rows[i]["SHIPMENT_QUANTITY"])) { _currentDt.Rows[i]["SHIPMENT_NAME"] = "欠品"; } else { _currentDt.Rows[i]["SHIPMENT_NAME"] = "完了"; } #endregion } if (_currentDt != null) { int result = CommonExport.DataTableToExcel(_currentDt, CConstant.ORDER_HEADER, CConstant.ORDER_COLUMNS, "ORDER", "ORDER"); if (result == CConstant.EXPORT_SUCCESS) { MessageBox.Show("导出成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (result == CConstant.EXPORT_FAILURE) { MessageBox.Show("数据导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("没有可以导出的数据。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public decimal GetGetInvoiceAmount(string RECEIPT_SLIP_NUMBER) { StringBuilder strSql = new StringBuilder(); strSql.Append(" SELECT INVOICE_AMOUNT from bll_purchase_invoice_amount_view "); strSql.Append(" WHERE RECEIPT_SLIP_NUMBER = @RECEIPT_SLIP_NUMBER "); SqlParameter[] parameters = { new SqlParameter("@RECEIPT_SLIP_NUMBER", SqlDbType.VarChar, 20) }; parameters[0].Value = RECEIPT_SLIP_NUMBER; return(CConvert.ToDecimal(DbHelperSQL.GetSingle(strSql.ToString(), parameters))); }
// 保存前的验证 public bool saveCheck() { if (CConvert.ToDecimal(txtQuantity.Text.Trim()) > CConvert.ToDecimal(txtPossibleQuantity.Text.Trim())) { txtQuantity.Text = txtPossibleQuantity.Text.Trim(); } if (CConvert.ToDecimal(txtPossibleQuantity.Text.Trim()) == 0) { MessageBox.Show("材料库存不够!"); return(false); } return(true); }
public decimal GetInvoiceAmount(string SHIPMENT_SLIP_NUMBER) { StringBuilder strSql = new StringBuilder(); strSql.Append(" SELECT INVOICE_AMOUNT from SALES_INVOICE_AMOUNT_VIEW "); strSql.Append(" WHERE SHIPMENT_SLIP_NUMBER = @SHIPMENT_SLIP_NUMBER "); SqlParameter[] parameters = { new SqlParameter("@SHIPMENT_SLIP_NUMBER", SqlDbType.VarChar, 20) }; parameters[0].Value = SHIPMENT_SLIP_NUMBER; return(CConvert.ToDecimal(DbHelperSQL.GetSingle(strSql.ToString(), parameters))); }
private void dgvData_CellValidated(object sender, DataGridViewCellEventArgs e) { DataGridViewRow dr = dgvData.Rows[e.RowIndex]; if (e.ColumnIndex == dgvData.Columns["START_DATE"].Index) { if (dr.Cells["START_DATE"].Value != null) { if (!r.IsMatch(dr.Cells["START_DATE"].Value.ToString().Trim())) { MessageBox.Show("请输入正确的日期。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); dgvData.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = ""; } } } else if (e.ColumnIndex == dgvData.Columns["END_DATE"].Index) { if (dr.Cells["END_DATE"].Value != null) { if (!r.IsMatch(dr.Cells["END_DATE"].Value.ToString().Trim())) { MessageBox.Show("请输入正确的日期。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); dgvData.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = ""; } } } else if (e.ColumnIndex == dgvData.Columns["PRODUCTION_CYCLE"].Index) { int j = 0; foreach (DataGridViewRow dr1 in dgvData.Rows) { string strWhere = " CODE = " + "'" + dr.Cells["PRODUCTION_PROCESS_CODE"].Value.ToString() + "'"; DataSet ds = BProductionProcess.GetList(strWhere); decimal productioncycle = CConvert.ToDecimal(ds.Tables[0].Rows[0]["PRODUCTION_CYCLE"].ToString().Trim()); if (j != 0) { dr1.Cells["START_DATE"].Value = CConvert.ToDateTime(dgvData.Rows[j - 1].Cells["END_DATE"].Value.ToString()).AddDays(1); dr1.Cells["END_DATE"].Value = CConvert.ToDateTime(dgvData.Rows[j].Cells["START_DATE"].Value.ToString()).AddDays(CConvert.ToDouble(dgvData.Rows[j].Cells["PRODUCTION_CYCLE"].Value) + 0D); j++; } else { dr1.Cells["START_DATE"].Value = txtSlipDateFrom.Text; dr1.Cells["END_DATE"].Value = CConvert.ToDateTime(txtSlipDateFrom.Text).AddDays(CConvert.ToDouble(dgvData.Rows[0].Cells["PRODUCTION_CYCLE"].Value) + 0D); j++; } } } }