You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
208 lines
9.7 KiB
208 lines
9.7 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Data.Linq;
|
|
using System.Linq;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraGrid.Views.BandedGrid;
|
|
using DevExpress.XtraGrid.Columns;
|
|
using DevExpress.XtraGrid;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using ICSSoft.Base.Language.Tool;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using ICSSoft.Base.UserControl.MessageControl;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
using ICSSoft.Base.Report.Filter;
|
|
using ICSSoft.Base.UserControl.FormControl;
|
|
using ICSSoft.Base.Report.GridReport;
|
|
using ICSSoft.Base.ReferForm.AppReferForm;
|
|
using ICSSoft.Frame.Data.BLL;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using ICSSoft.Frame.Data.DAL;
|
|
|
|
namespace ICSSoft.Frame.APP
|
|
{
|
|
public partial class FormMOBeginningAdd : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
DataRow rows;
|
|
#region 构造函数
|
|
public FormMOBeginningAdd()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
#endregion
|
|
|
|
#region 关闭 退出
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
{
|
|
this.DialogResult = DialogResult.Cancel;
|
|
}
|
|
private void can_Click(object sender, EventArgs e)
|
|
{
|
|
this.DialogResult = DialogResult.Cancel;
|
|
}
|
|
#endregion
|
|
|
|
#region 移动窗体
|
|
private const int WM_NCHITTEST = 0x84;
|
|
private const int HTCLIENT = 0x1;
|
|
private const int HTCAPTION = 0x2;
|
|
//首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
|
|
//系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
|
|
//假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
|
|
//同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
|
|
|
|
//重写窗体,使窗体可以不通过自带标题栏实现移动
|
|
protected override void WndProc(ref Message m)
|
|
{
|
|
|
|
|
|
//当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
|
|
//当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
|
|
//这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
|
|
//注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
|
|
switch (m.Msg)
|
|
{
|
|
case WM_NCHITTEST:
|
|
base.WndProc(ref m);
|
|
if ((int)m.Result == HTCLIENT)
|
|
m.Result = (IntPtr)HTCAPTION;
|
|
return;
|
|
}
|
|
//拦截双击标题栏、移动窗体的系统消息
|
|
if (m.Msg != 0xA3)
|
|
{
|
|
base.WndProc(ref m);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
private void save_Click(object sender, EventArgs e)
|
|
{
|
|
if (txtBatchCode.Text.Trim() == "")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("批次不可为空!");
|
|
return;
|
|
}
|
|
if (txtBatchQty.Text.Trim() == "")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("本次批次数量不可为空!");
|
|
return;
|
|
}
|
|
ICSSoft.Frame.Data.DAL.ICSMODAL.MoContext context = new ICSSoft.Frame.Data.DAL.ICSMODAL.MoContext();
|
|
context.cInvCode = txtItemCode.Text.Trim();
|
|
context.cInvName = txtItemName.Text.Trim();
|
|
context.cInvStd = txtItemStd.Text.Trim();
|
|
context.AuxQty = txtBatchQty.Text.Trim();
|
|
context.ChangeRate = txtChange.Text.Trim();
|
|
context.AuxUnitCode = txtChange.Tag.ToString();
|
|
context.Free1 = txtFree1.Text.Trim();
|
|
context.free2 = txtFree2.Text.Trim();
|
|
context.Free3 = txtFree3.Text.Trim();
|
|
context.Free4 = txtFree4.Text.Trim();
|
|
context.Qty = (decimal.Parse(txtBatchQty.Text.Trim()) * decimal.Parse(txtChange.Text.Trim() == "" ? "0" : txtChange.Text.Trim())).ToString();
|
|
context.cComUnitName1 = txtUnits.Tag.ToString();
|
|
context.MoCode = "";
|
|
context.MoDId = "";
|
|
context.MDeptCode = "";
|
|
context.cComUnitName2 = txtUnits.Text.Trim();
|
|
context.BatchCode = txtBatchCode.Text.Trim();
|
|
context.Whcode = txtItemCode.Tag.ToString();
|
|
|
|
try {
|
|
ICSMODAL.BeginningSave(context);
|
|
ICSBaseSimpleCode.AppshowMessageBox("修改成功!!");
|
|
this.Close();
|
|
}catch(Exception ex){
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
private void FormPurchasingAdd_Load(object sender, EventArgs e)
|
|
{
|
|
// string sql = @"SELECT ItemCode,ItemName,ItemStd,ComUnit,AssComUnit,AuxQty,BatchCode
|
|
// FROM dbo.ICSMO WHERE Serial = '" + MOSerial + "'";
|
|
// DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
// if (dt == null || dt.Rows.Count == 0)
|
|
// {
|
|
// return;
|
|
// }
|
|
// txtItemCode.Text = dt.Rows[0]["ItemCode"].ToString();
|
|
// txtItemName.Text = dt.Rows[0]["ItemName"].ToString();
|
|
// txtItemsStd.Text = dt.Rows[0]["ItemStd"].ToString();
|
|
// txtUNIT.Text = dt.Rows[0]["ComUnit"].ToString();
|
|
// txtUnits.Text = dt.Rows[0]["AssComUnit"].ToString();
|
|
// txtFqty.Text = dt.Rows[0]["AuxQty"].ToString();
|
|
// txtBatchCode.Text = dt.Rows[0]["BatchCode"].ToString();
|
|
// if (txtItemCode.Text.Trim().Substring(0, 2) == "05")
|
|
// {
|
|
// txtBatchCode.Properties.ReadOnly = false;
|
|
// }
|
|
}
|
|
|
|
private void txtItemName_Properties_Leave(object sender, EventArgs e)
|
|
{
|
|
if (txtItemName.Text.Trim() == "") return;
|
|
#region 产品别
|
|
string sql = @"SELECT a.cWhCode as 仓库,a.cInvCode AS 存货编码,b.cInvName AS 存货名称,
|
|
b.cInvStd AS 规格型号,convert(decimal(18,2),a.iQuantity/ISNULL(c.iChangRate,1)) AS ERP数量,a.cFree1 AS 上膜,
|
|
a.cFree2 AS 下膜,a.cFree3 AS 定制,a.cFree4 AS 不良原因,
|
|
c.cComUnitName AS 辅计量单位,c.iChangRate AS 转换率,a.autoid as 现存量ID
|
|
FROM {0}.dbo.CurrentStock a
|
|
INNER JOIN {0}.dbo.Inventory b ON a.cInvCode = b.cInvCode
|
|
LEFT JOIN {0}.dbo.ComputationUnit c ON b.cSTComUnitCode = c.cComunitCode
|
|
WHERE b.cInvName = '{1}' and a.iQuantity>0";
|
|
sql = string.Format(sql,ICSBaseSimpleCode.GetWorkPointErpData(),txtItemName.Text.Trim());
|
|
DataTable classDt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
txtItemStd.Properties.ValueMember = "现存量ID";
|
|
txtItemStd.Properties.DisplayMember = "规格型号";
|
|
txtItemStd.Properties.DataSource = classDt;
|
|
txtItemStd.Properties.NullText = "";//空时的值
|
|
txtItemStd.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
|
|
txtItemStd.Properties.ValidateOnEnterKey = true;//回车确认
|
|
txtItemStd.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
|
|
txtItemStd.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
|
|
//自适应宽度
|
|
txtItemStd.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
|
|
#endregion
|
|
}
|
|
|
|
private void txtItemStd_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
if (txtItemStd.Text.Trim() != "")
|
|
{
|
|
string sql = @"SELECT a.cWhCode as 仓库,a.cInvCode AS 存货编码,
|
|
CONVERT(decimal(18,2),a.iQuantity/ISNULL(c.iChangRate,1)) AS ERP数量,a.cFree1 AS 上膜,
|
|
a.cFree2 AS 下膜,a.cFree3 AS 定制,a.cFree4 AS 不良原因,c.cComunitCode,d.cComUnitName as 主计量单位,
|
|
c.cComUnitName AS 辅计量单位,c.iChangRate AS 转换率
|
|
FROM {0}.dbo.CurrentStock a
|
|
INNER JOIN {0}.dbo.Inventory b ON a.cInvCode = b.cInvCode
|
|
LEFT JOIN {0}.dbo.ComputationUnit c ON b.cSTComUnitCode = c.cComunitCode
|
|
LEFT JOIN {0}.dbo.ComputationUnit d ON b.cComUnitCode = d.cComunitCode
|
|
WHERE a.AutoID = '{1}'";
|
|
sql = string.Format(sql,ICSBaseSimpleCode.GetWorkPointErpData(),txtItemStd.EditValue.ToString());
|
|
DataTable Dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
txtItemCode.Text = Dt.Rows[0]["存货编码"].ToString();
|
|
txtItemCode.Tag = Dt.Rows[0]["仓库"].ToString();
|
|
txtFree1.Text = Dt.Rows[0]["上膜"].ToString();
|
|
txtFree2.Text = Dt.Rows[0]["下膜"].ToString();
|
|
txtFree3.Text = Dt.Rows[0]["定制"].ToString();
|
|
txtFree4.Text = Dt.Rows[0]["不良原因"].ToString();
|
|
txtERPqty.Text = Dt.Rows[0]["ERP数量"].ToString();
|
|
txtUnits.Text = Dt.Rows[0]["辅计量单位"].ToString();
|
|
txtUnits.Tag = Dt.Rows[0]["主计量单位"].ToString();
|
|
txtChange.Text = Dt.Rows[0]["转换率"].ToString();
|
|
txtChange.Tag = Dt.Rows[0]["cComunitCode"].ToString();
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|