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.
782 lines
37 KiB
782 lines
37 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Windows.Forms;
|
|
using DevExpress.XtraEditors;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
using ICSSoft.Base.ReferForm.AppReferForm;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using ICSSoft.Frame.Data.BLL;
|
|
|
|
namespace ICSSoft.Frame.APP
|
|
{
|
|
public partial class FormICSSOPriceSheetEditAdd : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
string VRow = "";
|
|
String guid = "";
|
|
string SoCode = "";
|
|
XS001_0001_E001_2020 entity = new XS001_0001_E001_2020();
|
|
private DataTable dtNewRcards = null;
|
|
|
|
#region 构造函数
|
|
public FormICSSOPriceSheetEditAdd()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
public FormICSSOPriceSheetEditAdd(String id,string socode)
|
|
{
|
|
InitializeComponent();
|
|
guid = id;
|
|
SoCode = socode;
|
|
}
|
|
#endregion
|
|
|
|
#region 关闭 退出
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
#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
|
|
|
|
#region 取消
|
|
private void can_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
#endregion
|
|
|
|
#region 页面加载
|
|
private void FormICSINVENTORYEditAdd_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
if (guid != "")
|
|
{
|
|
decimal sumsinglemoney = 0;
|
|
lblTitle.Text = "单据维护";
|
|
DataTable body = ICSSOPriceSheetBLL.GetDetailList(guid, AppConfig.GetDataBaseConnectStringByKey("[DB.ERP]"));
|
|
grvDetail.DataSource = body;
|
|
dtNewRcards = body;
|
|
//grdDetail.BestFitColumns();
|
|
txtSOCode.Enabled = false;
|
|
checkAll.Enabled = false;
|
|
checkAll.Checked = true;
|
|
init();
|
|
loadop();
|
|
foreach (DataRow dr in body.Rows)
|
|
{
|
|
if (body.Rows.Count > 0)
|
|
{
|
|
txtSOCode.EditValue = dr["IDs"].ToString().Trim();
|
|
txtCode.Text = dr["ID"].ToString().Trim();
|
|
txtSOType.Text = dr["cSoType"].ToString().Trim();
|
|
txtCusName.Text = dr["cCusName"].ToString().Trim();
|
|
txtInvCode.Text = dr["InvCodes"].ToString().Trim();
|
|
txtInvName.Text = dr["InvName"].ToString().Trim();
|
|
txtNumber.Text = dr["iNum"].ToString().Trim();
|
|
txtDNumber.Text = dr["cInvStd"].ToString().Trim();
|
|
txtWeight.Text = dr["iWeight"].ToString().Trim();
|
|
txtOpQuire.Text = dr["cinvtype"].ToString().Trim();
|
|
txtdDate.Text = dr["dDate"].ToString().Trim();
|
|
txtSumSingleMoney.Text = dr["iPrice"].ToString().Trim();
|
|
}
|
|
}
|
|
for (int i = 0; i < grdDetail.RowCount; i++)
|
|
{
|
|
if (grdDetail.GetRowCellValue(i, colSingleMoney).ToString() == "")
|
|
{
|
|
sumsinglemoney = sumsinglemoney + 0;
|
|
}
|
|
else
|
|
{
|
|
sumsinglemoney = sumsinglemoney + Convert.ToDecimal(grdDetail.GetRowCellValue(i, colSingleMoney).ToString());
|
|
txtSumMoney.Text = Convert.ToString(sumsinglemoney);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lblTitle.Text = "单据新增";
|
|
txtCode.Text = ICSSOPriceSheetBLL.GetOutInNo(AppConfig.GetDataBaseConnectStringByKey("[DB.ERP]"));
|
|
init();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 初始化查询条件
|
|
private void init()
|
|
{
|
|
#region 销售订单号
|
|
string sql = @"SELECT DISTINCT a.cSOCode 销售订单号,b.cInvCode 存货编码, b.cdefine24 工艺要求,
|
|
(CASE WHEN isnull(c.cSOCode,'')='' THEN '未维护' ELSE '已维护' END ) as 状态,
|
|
a.cSOCode+b.cInvCode+ISNULL(b.cdefine24, '') as ID
|
|
FROM SO_SOMain a with(nolock)
|
|
LEFT JOIN SO_SODetails b with(nolock) on b.cSOCode=a.cSOCode
|
|
left JOIN dbo.XS001_0001_E001_2020 c with(nolock) ON a.cSOCode=c.cSOCode and isnull(b.cinvcode,'')=isnull(c.cinvcode,'')
|
|
and isnull(b.cdefine24,'')=isnull(c.cinvtype,'')
|
|
WHERE a.dDate>='2020-08-01' ";
|
|
sql = string.Format(sql, AppConfig.WorkPointCode);
|
|
if (!checkAll.Checked)
|
|
{
|
|
sql += " AND c.cSOCode is null";
|
|
}
|
|
else
|
|
{
|
|
sql += " AND 1=1 ";
|
|
}
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.ERP]"), CommandType.Text, sql).Tables[0];
|
|
txtSOCode.Properties.ValueMember = "ID";
|
|
txtSOCode.Properties.DisplayMember = "销售订单号";
|
|
txtSOCode.Properties.DataSource = dt;
|
|
txtSOCode.Properties.NullText = "";//空时的值
|
|
//txtSOCode.Properties.View.Columns["ID"].Visible = false; //隐藏列
|
|
txtSOCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
|
|
txtSOCode.Properties.ValidateOnEnterKey = true;//回车确认
|
|
txtSOCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
|
|
txtSOCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
|
|
//自适应宽度
|
|
txtSOCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
|
|
#endregion
|
|
|
|
#region 存货编码
|
|
string sqls = @"SELECT DISTINCT cInvCode as 存货编码,cInvName as 存货名称,cInvStd as 图号 FROM Inventory";
|
|
DataTable dts = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.ERP]"), CommandType.Text, sqls).Tables[0];
|
|
txtcInvCode.Properties.ValueMember = "存货编码";
|
|
txtcInvCode.Properties.DisplayMember = "存货编码";
|
|
txtcInvCode.Properties.DataSource = dts;
|
|
txtcInvCode.Properties.NullText = "";//空时的值
|
|
//txtSOCode.Properties.View.Columns["ID"].Visible = false; //隐藏列
|
|
txtcInvCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
|
|
txtcInvCode.Properties.ValidateOnEnterKey = true;//回车确认
|
|
txtcInvCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
|
|
txtcInvCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
|
|
//自适应宽度
|
|
txtcInvCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
|
|
#endregion
|
|
}
|
|
#endregion
|
|
|
|
#region 销售订单号
|
|
private void txtSOCode_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string Code = txtSOCode.Text;
|
|
string socode = "";
|
|
string invcode="";
|
|
string invtype="";
|
|
#region 判断销售订单号是否维护
|
|
GridLookUpEdit edit = sender as GridLookUpEdit;
|
|
if (edit.EditValue != null && edit.EditValue.ToString() != "" && edit.EditValue.ToString() != "nulltext")
|
|
{
|
|
var o = edit.Properties.GetRowByKeyValue(edit.EditValue);
|
|
if (o is DataRowView)
|
|
{
|
|
DataRowView RowView = o as DataRowView;
|
|
socode = RowView.Row["销售订单号"].ToString();
|
|
invcode = RowView.Row["存货编码"].ToString();
|
|
invtype = RowView.Row["工艺要求"].ToString();
|
|
}
|
|
}
|
|
string sqlso = @"SELECT cSOCode FROM XS001_0001_E001_2020 WHERE cSOCode='{0}' AND cInvCode='{1}' AND cinvtype='{2}'";
|
|
sqlso = string.Format(sqlso, Code, invcode, invtype);
|
|
DataTable dtso = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.ERP]"), CommandType.Text, sqlso).Tables[0];
|
|
if (dtso != null && dtso.Rows.Count > 0&&guid=="")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("该销售订单号已经维护,不能选择!!!");
|
|
init();
|
|
return;
|
|
}
|
|
#endregion
|
|
#region 查询
|
|
string sql = @"select
|
|
a.ddate 销售订单日期,
|
|
a.cSOCode 销售订单号,
|
|
d.cSTName 销售类型,
|
|
a.cCusName 客户名称,
|
|
b.cInvCode 存货编码,
|
|
b.cinvname 存货名称,
|
|
c.cinvstd 图号,
|
|
b.cdefine24 工艺要求,
|
|
CAST(isnull(SUM(b.iquantity),0) as NUMERIC(10,2)) 数量,
|
|
CAST(isnull(sum(b.iNum),0) as NUMERIC(10,2)) 重量,
|
|
CAST(isnull(SUM(b.iNatSum),0)/isnull(SUM(b.iquantity),0) as NUMERIC(18,6)) as 产品单价
|
|
from SO_SOMain a with(nolock)
|
|
inner join SO_SODetails b with(nolock) on b.cSOCode=a.cSOCode
|
|
inner join inventory c with(nolock) on c.cinvcode=b.cinvcode
|
|
inner join SaleType d with(nolock) on d.cstcode=a.cstcode
|
|
WHERE a.dDate>='2020-08-01' AND a.cSOCode='{0}' and b.cInvCode='{1}' and ISNULL(b.cdefine24, '')='{2}'
|
|
group by a.cSOCode,a.cCusName,b.cInvCode,b.cinvname,
|
|
b.cdefine24,c.cinvstd,d.cSTName,a.ddate";
|
|
sql = string.Format(sql, Code,invcode,invtype, AppConfig.WorkPointCode);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.ERP]"), CommandType.Text, sql).Tables[0];
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
txtCusName.Text = dt.Rows[0]["客户名称"].ToString();
|
|
txtSOType.Text = dt.Rows[0]["销售类型"].ToString();
|
|
txtNumber.Text = dt.Rows[0]["数量"].ToString();
|
|
txtInvCode.Text = dt.Rows[0]["存货编码"].ToString();
|
|
txtInvName.Text = dt.Rows[0]["存货名称"].ToString();
|
|
txtDNumber.Text = dt.Rows[0]["图号"].ToString();
|
|
txtWeight.Text = dt.Rows[0]["重量"].ToString();
|
|
txtOpQuire.Text = dt.Rows[0]["工艺要求"].ToString();
|
|
txtdDate.Text = dt.Rows[0]["销售订单日期"].ToString();
|
|
txtSumSingleMoney.Text = dt.Rows[0]["产品单价"].ToString();
|
|
#region 新增时带出默认工序
|
|
if (guid == "")
|
|
{
|
|
string sqlop = @"select DISTINCT
|
|
'Y' as isSelect,
|
|
a.cSOCode as SOCode,
|
|
'' as SORow,
|
|
--1 as SORow,
|
|
b.cInvCode InvCode,
|
|
b.cinvname InvName,
|
|
c.cinvstd DNumber,
|
|
'材料费' as QuotationItem,
|
|
'CL' OpCode,
|
|
'' as SingleMoney,
|
|
'' as Memo
|
|
from dbo.SO_SOMain a with(nolock)
|
|
inner join dbo.SO_SODetails b with(nolock) on b.cSOCode=a.cSOCode
|
|
inner join dbo.inventory c with(nolock) on c.cinvcode=b.cinvcode
|
|
WHERE b.cInvCode='{0}' and a.cSOCode='{2}'
|
|
UNION ALL
|
|
select DISTINCT
|
|
'Y' as isSelect,
|
|
a.cSOCode as SOCode,
|
|
'' as SORow,
|
|
--row_number() OVER (ORDER BY a.cSCCode)+1 as SORow,
|
|
b.cInvCode InvCode,
|
|
b.cinvname InvName,
|
|
c.cinvstd DNumber,
|
|
f.OPDESC as QuotationItem,
|
|
f.OPCODE as OpCode,
|
|
'' as SingleMoney,
|
|
'' as Memo
|
|
from dbo.SO_SOMain a with(nolock)
|
|
inner join dbo.SO_SODetails b with(nolock) on b.cSOCode=a.cSOCode
|
|
inner join dbo.inventory c with(nolock) on c.cinvcode=b.cinvcode
|
|
-- INNER JOIN [{1}].[ICSMES_YTSys].dbo.ICSITEM2ROUTE d ON b.cInvCode=d.itemcode
|
|
-- INNER JOIN [{1}].[ICSMES_YTSys].dbo.ICSITEMROUTE2OP e ON d.ROUTECODE=e.ROUTECODE
|
|
-- INNER JOIN [{1}].[ICSMES_YTSys].dbo.ICSOP f ON e.OPID=f.ID
|
|
INNER JOIN(
|
|
select
|
|
distinct
|
|
a.OPCODE,d.OPDESC,e.cInvCode
|
|
from [{1}].[ICSMES_YTSys].dbo.ICSITEMROUTE2OPLot a with(nolock)
|
|
inner join [{1}].[ICSMES_YTSys].dbo.ICSOP d with(nolock) on d.OPCODE=a.OPCODE
|
|
inner join [{1}].[ICSMES_YTSys].dbo.ICSITEMLot b with(nolock) on b.LotNO=a.LotNo
|
|
inner join [{1}].[ICSMES_YTSys].dbo.icsmo c with(nolock) on c.MOCODE=b.TransNO and c.MOSEQ=b.TransLine
|
|
left join
|
|
(select
|
|
DISTINCT
|
|
b.cSOCode,b.cInvCode,cDefine24
|
|
from dbo.SO_SOMain a with(nolock)
|
|
inner join dbo.SO_SODetails b with(nolock) on b.cSOCode=a.cSOCode
|
|
where a.dDate>'2020-08-01 00:00:00.000'
|
|
) e on e.cSOCode=c.ORDERNO and e.cinvcode=a.ITEMCODE and e.cdefine24=c.REMOITEMDESC
|
|
where e.cSOCode='{2}'
|
|
)f on f.cInvCode=b.cInvCode
|
|
WHERE b.cInvCode='{0}' and a.cSOCode='{2}'";
|
|
#region 获取MES地址
|
|
string sqlip = "SELECT DBIpAddress FROM Sys_DataBase WHERE DBSourceName='SYS'";
|
|
sqlip = string.Format(sqlip, AppConfig.AppConnectString);
|
|
DataTable dtip = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlip).Tables[0];
|
|
#endregion
|
|
sqlop = string.Format(sqlop, txtInvCode.Text, dtip.Rows[0]["DBIpAddress"].ToString(), txtSOCode.Text);
|
|
DataTable dtop = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.ERP]"), CommandType.Text, sqlop).Tables[0];
|
|
grvDetail.DataSource = dtop;
|
|
dtNewRcards = dtop;
|
|
//grdDetail.BestFitColumns();
|
|
}
|
|
#endregion
|
|
loadop();
|
|
}
|
|
#endregion
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.ToString());
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载工序
|
|
private void loadop()
|
|
{
|
|
#region 工序代码
|
|
string sqls = @"SELECT DISTINCT opcode as [工序代码],OPDESC as [工序名称] FROM ICSOP WHERE WorkPoint='{0}'";
|
|
sqls = string.Format(sqls, AppConfig.WorkPointCode);
|
|
DataTable dts = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqls).Tables[0];
|
|
txtOPCode.Properties.ValueMember = "工序代码";
|
|
txtOPCode.Properties.DisplayMember = "工序代码";
|
|
txtOPCode.Properties.DataSource = dts;
|
|
txtOPCode.Properties.NullText = "";//空时的值
|
|
txtOPCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
|
|
txtOPCode.Properties.ValidateOnEnterKey = true;//回车确认
|
|
txtOPCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
|
|
txtOPCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
|
|
//自适应宽度
|
|
txtOPCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
|
|
#endregion
|
|
}
|
|
#endregion
|
|
|
|
#region 工序代码
|
|
private void txtOPCode_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
GridLookUpEdit edit = sender as GridLookUpEdit;
|
|
if (edit.EditValue != null && edit.EditValue.ToString() != "" && edit.EditValue.ToString() != "nulltext")
|
|
{
|
|
var o = edit.Properties.GetRowByKeyValue(edit.EditValue);
|
|
if (o is DataRowView)
|
|
{
|
|
DataRowView RowView = o as DataRowView;
|
|
//赋值
|
|
txtOPName.Text = RowView.Row["工序名称"].ToString();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.ToString());
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 新增工序
|
|
private void btnAdd_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (txtSOCode.Text == "")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("销售订单号不能为空!");
|
|
return;
|
|
}
|
|
if (txtOPName.Text == "")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("工序名不能为空!");
|
|
return;
|
|
}
|
|
#region 判断工序不能重复添加
|
|
for (int i = 0; i < grdDetail.RowCount; i++)
|
|
{
|
|
if (txtOPName.Text.Equals(grdDetail.GetRowCellValue(i, colQuotationItem).ToString()))
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("工序:" + txtOPName.Text + ",在第" + Convert.ToInt32(i + 1) + "行已维护!");
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
if (grdDetail.RowCount > 0)
|
|
{
|
|
DataRow[] isRow = dtNewRcards.Select("QuotationItem= '材料费'");
|
|
if (isRow != null || isRow.Length > 0)
|
|
{
|
|
DataRow row = dtNewRcards.NewRow();
|
|
row["isSelect"] = "Y";
|
|
row["SOCode"] = txtSOCode.Text;//销售订单号
|
|
row["SORow"] = dtNewRcards.Rows.Count + 1;
|
|
row["InvCode"] = txtInvCode.Text;
|
|
row["InvName"] = txtInvName.Text;
|
|
row["DNumber"] = txtDNumber.Text;//图号
|
|
row["QuotationItem"] = txtOPName.Text;//报价项目
|
|
row["OpCode"] = txtOPCode.Text;//工序
|
|
if (guid == "")
|
|
{
|
|
row["SingleMoney"] = "";
|
|
}
|
|
else
|
|
{
|
|
row["SingleMoney"] = 0;
|
|
}
|
|
row["Memo"] = txtMemo.Text;
|
|
dtNewRcards.Rows.Add(row);
|
|
grvDetail.DataSource = dtNewRcards;
|
|
//grdDetail.BestFitColumns();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.ToString());
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 保存
|
|
private void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
|
|
try
|
|
{
|
|
_wait.Show();
|
|
List<XS001_0001_E001_2020> SoMainList = new List<XS001_0001_E001_2020>();
|
|
List<XS001_0001_E002_2020> SoDetailLIist = new List<XS001_0001_E002_2020>();
|
|
XS001_0001_E001_2020 SoMain = new XS001_0001_E001_2020();
|
|
SoMain.ID = txtCode.Text;//单据号
|
|
if (guid != "")
|
|
{
|
|
SoMain.cSOCode = SoCode;//销售订单号
|
|
}
|
|
else
|
|
{
|
|
SoMain.cSOCode = txtSOCode.Text;//销售订单号
|
|
}
|
|
SoMain.cCusName = txtCusName.Text;//客户名称
|
|
SoMain.cSoType = txtSOType.Text;//销售类型
|
|
SoMain.iNum = Convert.ToDecimal(txtNumber.Text);//数量
|
|
if (txtSumSingleMoney.Text == "")
|
|
{
|
|
SoMain.iPrice = 0;
|
|
}
|
|
else
|
|
{
|
|
SoMain.iPrice = Convert.ToDecimal(txtSumSingleMoney.Text);//产品单价
|
|
}
|
|
SoMain.cInvCode = txtInvCode.Text;//存货编码
|
|
SoMain.cInvName = txtInvName.Text;//存货名称
|
|
SoMain.cInvStd = txtDNumber.Text;//图号
|
|
SoMain.cinvtype = txtOpQuire.Text;//工艺要求
|
|
SoMain.iWeight = Convert.ToDecimal(txtWeight.Text);//重量
|
|
SoMain.cMake = AppConfig.UserName;//维护人
|
|
SoMain.dMakeTime = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");//维护时间
|
|
SoMain.dDate = Convert.ToDateTime(txtdDate.Text);//销售订单日期
|
|
SoMainList.Add(SoMain);
|
|
for (int i = 0; i < grdDetail.RowCount; i++)
|
|
{
|
|
if (grdDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
{
|
|
XS001_0001_E002_2020 SoDetail = new XS001_0001_E002_2020();
|
|
SoDetail.RefMainID = txtCode.Text;//单据号
|
|
if (guid == "")
|
|
{
|
|
SoDetail.RefRowID = Convert.ToString(i + 1);//行号
|
|
}
|
|
else
|
|
{
|
|
SoDetail.RefRowID = grdDetail.GetRowCellValue(i, colSORow).ToString();//行号
|
|
}
|
|
SoDetail.cInvCode = grdDetail.GetRowCellValue(i, colInvCode).ToString();//存货编码
|
|
SoDetail.cInvName = grdDetail.GetRowCellValue(i, colInvName).ToString();//存货名称
|
|
SoDetail.cInvStd = grdDetail.GetRowCellValue(i, colDNumber).ToString();//图号
|
|
SoDetail.cItem = grdDetail.GetRowCellValue(i, colQuotationItem).ToString();//报价项目
|
|
SoDetail.XS001_0001_E001_PK = Convert.ToString(grdDetail.GetRowCellValue(i, colOpCode).ToString());//工序
|
|
if (string.IsNullOrWhiteSpace(grdDetail.GetRowCellValue(i, colSingleMoney).ToString()))
|
|
{
|
|
SoDetail.iPrice = 0;
|
|
}
|
|
else
|
|
{
|
|
SoDetail.iPrice = Convert.ToDecimal(grdDetail.GetRowCellValue(i, colSingleMoney).ToString());//含税单价
|
|
}
|
|
SoDetail.UAP_VoucherTransform_Rowkey = txtMemo.Text;//备注
|
|
SoDetailLIist.Add(SoDetail);
|
|
}
|
|
}
|
|
if (SoMainList.Count <= 0)
|
|
{
|
|
_wait.Close();
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择数据!!!");
|
|
return;
|
|
}
|
|
ICSSOPriceSheetBLL.Add(SoMainList, SoDetailLIist, AppConfig.GetDataBaseConnectStringByKey("[DB.ERP]"));
|
|
_wait.Close();
|
|
ICSBaseSimpleCode.AppshowMessageBox("保存成功");
|
|
this.Close();
|
|
FormICSINVENTORYEditAdd_Load(null,null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_wait.Close();
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.ToString());
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
private void btnDelete_Click(object sender, EventArgs e)
|
|
{
|
|
grdDetail.PostEditor();
|
|
this.Validate();
|
|
if (grdDetail.RowCount == 0)
|
|
return;
|
|
string code = "";
|
|
string row = "";
|
|
if (grdDetail.GetRowCellValue(grdDetail.FocusedRowHandle, colQuotationItem).ToString() == "材料费" && grdDetail.GetRowCellValue(grdDetail.FocusedRowHandle, colSORow).ToString() == "1")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("第一行材料费数据不能删除!!!");
|
|
return;
|
|
}
|
|
for (int i = 0; i < grdDetail.RowCount; i++)
|
|
{
|
|
if (grdDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
{
|
|
code = grdDetail.GetRowCellValue(i, colSOCode).ToString();
|
|
row = grdDetail.GetRowCellValue(i, colSORow).ToString();
|
|
}
|
|
}
|
|
if (code=="")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
|
|
return;
|
|
}
|
|
if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除该行信息吗?删除后无法恢复,确定吗?") != DialogResult.OK)
|
|
return;
|
|
try
|
|
{
|
|
ICSSOPriceSheetBLL.deleteDetailInfo(code, row, AppConfig.GetDataBaseConnectStringByKey("[DB.ERP]"));
|
|
ICSBaseSimpleCode.AppshowMessageBox(0, "删除成功");
|
|
FormICSINVENTORYEditAdd_Load(null,null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.ToString());
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 删除窗体行
|
|
private void repositoryItemButtonEdit4_Click(object sender, EventArgs e)
|
|
{
|
|
if (grdDetail.GetRowCellValue(grdDetail.FocusedRowHandle, colQuotationItem).ToString() == "材料费" && grdDetail.GetRowCellValue(grdDetail.FocusedRowHandle, colSORow).ToString()=="1")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("第一行材料费数据不能删除!!!");
|
|
return;
|
|
}
|
|
grdDetail.DeleteRow(grdDetail.FocusedRowHandle);
|
|
}
|
|
#endregion
|
|
|
|
#region 双击
|
|
private void grdDetail_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
if (grdDetail.FocusedRowHandle < 0)
|
|
{
|
|
return;
|
|
}
|
|
for (int i = 0; i < grdDetail.RowCount; i++)
|
|
{
|
|
grdDetail.SetRowCellValue(i, colisSelect, "");
|
|
}
|
|
if (grdDetail.FocusedColumn == colisSelect)
|
|
{
|
|
if (grdDetail.GetRowCellValue(grdDetail.FocusedRowHandle, colisSelect).ToString() == "")
|
|
{
|
|
grdDetail.SetRowCellValue(grdDetail.FocusedRowHandle, colisSelect, "Y");
|
|
}
|
|
else
|
|
{
|
|
grdDetail.SetRowCellValue(grdDetail.FocusedRowHandle, colisSelect, "");
|
|
}
|
|
}
|
|
string code = "";
|
|
string row = "";
|
|
for (int i = 0; i < grdDetail.RowCount; i++)
|
|
{
|
|
if (grdDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
{
|
|
code = grdDetail.GetRowCellValue(i, colSOCode).ToString();
|
|
row = grdDetail.GetRowCellValue(i, colSORow).ToString();
|
|
}
|
|
}
|
|
DataTable dt = ICSSOPriceSheetBLL.GetDetailInfo(code, row, AppConfig.GetDataBaseConnectStringByKey("[DB.ERP]"));
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
txtOPCode.Text = dr["XS001_0001_E001_PK"].ToString().Trim();
|
|
txtOPName.Text = dr["XS001_0001_E002_PK"].ToString().Trim();
|
|
txtMemo.Text = dr["UAP_VoucherTransform_Rowkey"].ToString().Trim();
|
|
txtOPCode.Enabled = false;
|
|
txtMemo.Enabled = false;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 计算含税单价
|
|
private void grdDetail_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (e.Column.FieldName == "SingleMoney")
|
|
{
|
|
decimal singlemoney=0;
|
|
decimal summoney = 0;
|
|
if (string.IsNullOrWhiteSpace(grdDetail.GetRowCellValue(e.RowHandle, colSingleMoney).ToString()))
|
|
{
|
|
singlemoney = 0;
|
|
}
|
|
else
|
|
{
|
|
singlemoney = Convert.ToDecimal(grdDetail.GetRowCellValue(e.RowHandle, colSingleMoney).ToString());
|
|
}
|
|
if (txtSumMoney.Text == "0.00")
|
|
{
|
|
txtSumMoney.Text = Convert.ToString(0 + singlemoney);
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0; i < grdDetail.RowCount; i++)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(grdDetail.GetRowCellValue(i, colSingleMoney).ToString()))
|
|
{
|
|
summoney += 0;
|
|
}
|
|
else
|
|
{
|
|
summoney += Convert.ToDecimal(grdDetail.GetRowCellValue(i, colSingleMoney).ToString());
|
|
}
|
|
}
|
|
txtSumMoney.Text = Convert.ToString(summoney);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 显示全部
|
|
private void checkAll_Click(object sender, EventArgs e)
|
|
{
|
|
init();
|
|
grvDetail.DataSource = null;
|
|
txtSOCode.Text = "";
|
|
txtSumSingleMoney.Text = "";
|
|
txtdDate.Text = "";
|
|
txtOpQuire.Text = "";
|
|
txtCusName.Text = "";
|
|
txtSOType.Text = "";
|
|
txtNumber.Text = "";
|
|
txtInvCode.Text = "";
|
|
txtInvName.Text = "";
|
|
txtDNumber.Text = "";
|
|
txtWeight.Text = "";
|
|
txtOPCode.Text = "";
|
|
txtOPName.Text = "";
|
|
txtMemo.Text = "";
|
|
}
|
|
#endregion
|
|
|
|
private void txtSOCode_QueryPopUp(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
txtSOCode.Properties.View.Columns["ID"].Visible = false; //隐藏列
|
|
}
|
|
|
|
#region 新增存货编码
|
|
private void btnAddInvName_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (txtcInvCode.Text == "")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("存货编码不能为空!");
|
|
return;
|
|
}
|
|
if (grdDetail.RowCount > 0)
|
|
{
|
|
DataRow[] isRow = dtNewRcards.Select("QuotationItem= '材料费'");
|
|
if (isRow != null || isRow.Length > 0)
|
|
{
|
|
DataRow row = dtNewRcards.NewRow();
|
|
row["isSelect"] = "Y";
|
|
row["SOCode"] = txtSOCode.Text;//销售订单号
|
|
row["SORow"] = dtNewRcards.Rows.Count + 1;
|
|
row["InvCode"] = txtcInvCode.Text;//存货编码
|
|
row["InvName"] = txtcInvName.Text;//存货名称
|
|
row["DNumber"] = txtcInvstd.Text;//图号
|
|
row["QuotationItem"] = "材料费";//报价项目
|
|
row["OpCode"] = "CL";//工序
|
|
if (guid == "")
|
|
{
|
|
row["SingleMoney"] = "";
|
|
}
|
|
else
|
|
{
|
|
row["SingleMoney"] = 0;
|
|
}
|
|
row["Memo"] = "";
|
|
for (int i = 0; i < grdDetail.RowCount; i++)
|
|
{
|
|
if (grdDetail.GetRowCellValue(i, colInvCode).ToString().Equals(txtcInvCode.Text) && row["QuotationItem"].Equals(grdDetail.GetRowCellValue(i, colQuotationItem).ToString()))
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("存货编码:" + txtcInvCode.Text + ",报价项目:材料费,在第" + Convert.ToInt32(i + 1) + "行已维护!");
|
|
return;
|
|
}
|
|
}
|
|
dtNewRcards.Rows.Add(row);
|
|
grvDetail.DataSource = dtNewRcards;
|
|
//grdDetail.BestFitColumns();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.ToString());
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 存货编码改变
|
|
private void txtcInvCode_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
GridLookUpEdit edit = sender as GridLookUpEdit;
|
|
if (edit.EditValue != null && edit.EditValue.ToString() != "" && edit.EditValue.ToString() != "nulltext")
|
|
{
|
|
var o = edit.Properties.GetRowByKeyValue(edit.EditValue);
|
|
if (o is DataRowView)
|
|
{
|
|
DataRowView RowView = o as DataRowView;
|
|
txtcInvName.Text = RowView.Row["存货名称"].ToString();
|
|
txtcInvstd.Text = RowView.Row["图号"].ToString();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.ToString());
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|