/// <summary> /// 根据盘点单、存货编码、批次查询盘点信息 /// </summary> /// <param name="connectionString"></param> /// <param name="checkVouchs"></param> /// <param name="?"></param> /// <returns></returns> /// <remarks>tianzhenyun 2013-07-03</remarks> public bool SelectCheckVouch(string connectionString, ref CheckVouchs checkVouchs, out string errMsg) { bool flag = false; errMsg = string.Empty; string strSql = string.Format(@"SELECT cv.* ,i.cInvName,i.cInvStd FROM (SELECT cCVCode,cInvCode,cCVBatch,iCVQuantity,iCVCQuantity,iMassDate,CASE cMassUnit WHEN 3 THEN '天' WHEN 2 THEN '月' WHEN 1 THEN '年' ELSE '' END AS cMassUnit,dMadeDate,dDisDate FROM dbo.CheckVouchs WHERE cCVCode='{0}' AND cInvCode='{1}' AND cCVBatch='{2}') cv INNER JOIN dbo.Inventory i ON cv.cInvCode = i.cInvCode", checkVouchs.cCVCode, checkVouchs.cInvCode, checkVouchs.cCVBatch); DataTable dt = DBHelperSQL.QueryTable(connectionString, strSql); if (dt == null || dt.Rows.Count == 0) { errMsg = "该存货不在此盘点单中!"; return(flag); } DataRow row = dt.Rows[0]; checkVouchs.cInvName = Cast.ToString(row["cInvName"]); checkVouchs.cInvStd = Cast.ToString(row["cInvStd"]); checkVouchs.iMassDate = Cast.ToInteger(row["iMassDate"]); checkVouchs.cMassUnit = Cast.ToString(row["cMassUnit"]); checkVouchs.dDisDate = Cast.ToDateTime(row["dDisDate"]); checkVouchs.dMadeDate = Cast.ToDateTime(row["dMadeDate"]); checkVouchs.iCVQuantity = Cast.ToDouble(row["iCVQuantity"]); flag = true; return(flag); }
/// <summary> /// 根据盘点单、存货编码、批次查询盘点信息 /// </summary> /// <param name="checkVouchs"></param> /// <param name="?"></param> /// <returns></returns> /// <remarks>tianzhenyun 2013-07-03</remarks> public bool SelectCheckVouch(ref CheckVouchs checkVouchs, out string errMsg) { BLL.Service.CheckVouchs tCheckVouchs = new BLL.Service.CheckVouchs(); tCheckVouchs = EntityConvert.ConvertClass <CheckVouchs, BLL.Service.CheckVouchs>(checkVouchs, tCheckVouchs); bool flag = BLL.Common.Instance.Service.SelectCheckVouch(Common.Instance.User.ConnectionString, ref tCheckVouchs, out errMsg); if (flag)//如果为真,则转换对象 { checkVouchs = EntityConvert.ConvertClass <BLL.Service.CheckVouchs, CheckVouchs>(tCheckVouchs, checkVouchs); } return(flag); }
/// <summary> /// 录入盘点数据回车 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtQuantity_KeyPress(object sender, KeyPressEventArgs e) { //获取界面数据 string strQuantity = txtQuantity.Text.Trim(); if (string.IsNullOrEmpty(strQuantity) || e.KeyChar != (char)Keys.Enter) { return; } double iQuantity; try { iQuantity = Convert.ToDouble(strQuantity); } catch (Exception ex) { MessageBox.Show(ex.Message); txtQuantity.Focus(); txtQuantity.SelectAll(); return; } //首先判断已扫集合中是否已包含 CheckVouchs cv = list.Find( delegate(CheckVouchs tch) { return(tch.cInvCode == barcode[0] && tch.cCVBatch == barcode[1]); }); //没有找到 if (cv == null) { checkVouchs.iCVCQuantity = iQuantity; list.Add(checkVouchs); } else { cv.iCVCQuantity = iQuantity;//覆盖 } Clear(); txtBarCode.Focus(); //如果不可用修改 if (!btnDetail.Enabled) { btnDetail.Enabled = btnSubmit.Enabled = true; } }
/// <summary> /// 扫描条码回车 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e) { string strBarCode = txtBarCode.Text.Trim(); if (!string.IsNullOrEmpty(strBarCode) && e.KeyChar == (char)Keys.Enter) { //判断条码中是否包含分隔符 if (strBarCode.IndexOf(Cast.Delimiter) < 0) { MessageBox.Show("条码错误,没有分隔符!"); txtBarCode.Focus(); txtBarCode.SelectAll(); return; } //解析QR码 barcode = strBarCode.Split(Cast.Delimiter); //判断条码是否正确 if (barcode.Length < 4) { MessageBox.Show("条码错误!"); txtBarCode.Focus(); txtBarCode.SelectAll(); return; } try { Cursor.Current = Cursors.WaitCursor; string errMsg; //封装数据 checkVouchs = new CheckVouchs(); checkVouchs.cCVCode = cCVCode; checkVouchs.cInvCode = barcode[0]; checkVouchs.cCVBatch = barcode[1]; //查询数据 bool flag = new BLL.CheckStock().SelectCheckVouch(ref checkVouchs, out errMsg); if (!flag) { MessageBox.Show(errMsg); txtBarCode.Focus(); txtBarCode.SelectAll(); return; } //绑定显示 lblInvName.Text = checkVouchs.cInvName; lblInvStd.Text = checkVouchs.cInvStd; lblcBatch.Text = checkVouchs.cCVBatch; lbldMDate.Text = checkVouchs.dMadeDate.ToShortDateString(); lbldVDate.Text = checkVouchs.dDisDate.ToShortDateString(); lblQuantity.Text = checkVouchs.iCVQuantity.ToString(); //盘点数据获取焦点 txtQuantity.Focus(); txtQuantity.SelectAll(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { Cursor.Current = Cursors.Default; } } }
public bool SelectCheckVouch(string connectionString, ref CheckVouchs checkVouchs, out string errMsg) { return(new DAL.CheckStock().SelectCheckVouch(connectionString, ref checkVouchs, out errMsg)); }