partial class frmAsnOrder : Smobiler.Core.Controls.MobileForm
{
public DataTable dts;
public String strField = "";
public DataTable dtbody;
public DataTable dthead;
public DataTable dttask;
public DataTable dtdetails; //明细
public DataTable dtBodys;//自定义表体数据
public Dictionary<string, double> dicbodyqty = new Dictionary<string, double>(); //明细数量
public Dictionary<string, string> diccabrcode = new Dictionary<string, string>(); //明细扫描条码
public List<string> strList = new List<string>(); //定义表体数据集合,用于赋值时判断(下方列表标题)
public List<string> deList = new List<string>(); //定义选中数据主键
public List<TableViewRow> detList = new List<TableViewRow>(); //定义删除表体集合
public int numdata = 0;
public frmAsnOrder() : base()
{
InitializeComponent();
}
//定义控件
private UserControl.UserTextBox tb;
private UserControl.datetime_UControl dtuc;
//初始页面
private void frmAsnOrder_Load(object sender, EventArgs e)
{
//datePicker1.Value = Convert.ToDateTime(Common.CuurentCommon.LoginDate);
title1.TitleText = "ASN单";
#region 表体数据
string connectionString = NJ.UTO.WMS.Client.GlobalCom.DBConnectionStr;
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
string strsql = "select * from GridViewConfig WHERE (localeid = 'zh-cn') AND (FormID = '采购入库') AND (FormType = 'list') AND (isShow = 1) order by [Index] desc ";
SqlCommand cmdcjeckqjqj = new SqlCommand(strsql, conn);
cmdcjeckqjqj.ExecuteNonQuery();
SqlDataReader readercheckqjqj = cmdcjeckqjqj.ExecuteReader();
var checkee = readercheckqjqj.HasRows;
if (checkee)
{
dtdetails = new DataTable();
TableViewCheckBoxColumn column2 = new TableViewCheckBoxColumn();
column2.DataMember = "id";//使用唯一值即可,并必须显示出来
column2.DisplayMember = "";
column2.HeaderText = "选择";
column2.Width = 50;
this.tableView1.Columns.Add(column2);
while (readercheckqjqj.Read())
{
TableViewLabelColumn column = new TableViewLabelColumn();
column.DataMember = readercheckqjqj["ColumnID"].ToString();
column.DisplayMember = readercheckqjqj["ColumnID"].ToString();
column.HeaderText = readercheckqjqj["ColumnText_u8"].ToString();
column.Width = Int32.Parse(readercheckqjqj["Width"].ToString());
column.HorizontalAlignment = HorizontalAlignment.Left;
this.tableView1.Columns.Add(column);
dtdetails.Columns.Add(readercheckqjqj["ColumnID"].ToString());
strList.Add(readercheckqjqj["ColumnID"].ToString());
strField = strField + " " + readercheckqjqj["ColumnID"].ToString() + ",";
}
}
strField = strField.TrimEnd(',');
conn.Close();
#endregion 表体数据
#region 表头数据
string strsql2 = "select * from GridViewConfig WHERE (localeid = 'zh-cn') AND (FormID = '采购入库') AND (FormType = 'details') AND (isShow = 1) order by [Index] desc";
DataTable dt = new System.Data.DataTable();
try
{
conn.Open();// 打开数据库连接
SqlCommand sqlcmd = new SqlCommand();//创建 Command 对象
sqlcmd.CommandText = string.Format(strsql2);//执行查询语句
sqlcmd.Connection = conn;
SqlDataAdapter adp = new SqlDataAdapter(sqlcmd);
adp.Fill(dt);
conn.Close();// 关闭数据库连接
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
throw;
}
//循环向panel中添加控件
dtBodys = dt;
int number = 1;//第一个在panel中的y轴位置
foreach (DataRow datarow in dt.Rows)
{
string sControlType = datarow["ControlType"].ToString();
//日期类型
if (sControlType == "datatime")
{
this.dtuc = new NJ.UTO.WMS.Client.UserControl.datetime_UControl();
this.dtuc.Direction = Smobiler.Core.Controls.LayoutDirection.Row;
this.dtuc.Layout = Smobiler.Core.Controls.LayoutPosition.Relative;
this.dtuc.Location = new System.Drawing.Point(22, 346);
this.dtuc.TitleText = datarow["ColumnText_u8"].ToString();
this.dtuc.Location = new System.Drawing.Point(15, number);
this.dtuc.Name = datarow["ColumnID"].ToString();
this.dtuc.Size = new System.Drawing.Size(260, 40);
this.panel2.Controls.AddRange(new Smobiler.Core.Controls.MobileControl[] {
dtuc});
}
//文本类型
else if (sControlType == "text")
{
this.tb = new NJ.UTO.WMS.Client.UserControl.UserTextBox();
this.tb.TitleText = datarow["ColumnText_u8"].ToString();
this.tb.TitleTag = datarow["ColumnText_u8"].ToString();
this.tb.showbtn = false;
this.tb.btnImage = "fulei";
if (datarow["isshowbtn"].ToString() == "1")
{
this.tb.btnStyle = NJ.UTO.WMS.Client.UserControl.UserTextBox.buttonStyle.Document; //是否显示按钮(不显示这行注销)
}
this.tb.Location = new System.Drawing.Point(15, number);
this.tb.Name = datarow["ColumnID"].ToString();
this.tb.Size = new System.Drawing.Size(275, 40);
this.tb.textFoucs = false;
this.tb.TextReadOnly = false;
this.tb.textContent = datarow["textContent"].ToString();
this.tb.TextTag = datarow["TextTag"].ToString();
//this.tb.Load += new System.EventHandler(this.tb_Load);
this.panel2.Controls.AddRange(new Smobiler.Core.Controls.MobileControl[] {
tb});
}
this.panel2.Location = new System.Drawing.Point(4, 76);
this.panel2.Name = "panel2";
this.panel2.Scrollable = true;
this.panel2.Size = new System.Drawing.Size(289, 151);
number = number + 30;
}
#endregion 表头数据
}
/// <summary>
/// 功能:扫码赋值的方法
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void barcodeScannerButton1_BarcodeScanned(object sender, BarcodeResultArgs e)
{
try
{
string s = e.Value;
//进行其他操作
this.textBox1.Text = s;
DataSet dsHead = new DataSet();
DataSet dsBody = new DataSet();
string ErrStr = "";
#region 表头数据
NJ.UTO.WMS.DataAccess.StockOutDA.GetU8ASNOrderHead(s, NJ.UTO.WMS.Client.GlobalCom.DBConnectionStr,
out dsHead, out ErrStr);
DataTable dtHead = new DataTable();
dtHead = dsHead.Tables[0];
if (dtHead == null || dtHead.Rows.Count <= 0)
{
RestBox();
Toast("扫描的条码没有对应的ASN单!");
return;
}
#endregion
#region 表体数据
NJ.UTO.WMS.DataAccess.StockOutDA.GetU8ASNOrderBody(dtHead.Rows[0]["poid"].ToString(), NJ.UTO.WMS.Client.GlobalCom.DBConnectionStr,
out dsBody, out ErrStr);
DataTable dtBody = new DataTable();
dtBody = dsBody.Tables[0];
if (dtBody == null || dtBody.Rows.Count <= 0)
{
Toast("该ASN单没有可操作的明细数据!");
return;
}
#endregion
#region 表头填充数据
Dictionary<string, object> data = new Dictionary<string, object>();
foreach (DataRow datarow in dtBodys.Rows)
{
data.Add(datarow["ColumnID"].ToString(), dtHead.Rows[0][datarow["ColumnID"].ToString()].ToString());
}
PanelHelper.InsertPanelValue(this.panel2.Controls, data);//插入panel中控件数据
#endregion
#region 表体填充数据
if (dtdetails != null && dtdetails.Rows.Count > 0)
{
dtdetails.Clear();
}
foreach (DataRow datarow in dtBody.Rows)
{
DataRow drdetail = dtdetails.NewRow();
for (int i = 0; i < strList.Count; i++)
{
drdetail[strList[i].ToString()] = datarow[strList[i].ToString()].ToString();
}
dtdetails.Rows.Add(drdetail);
}
tableView1.DataSource = dtdetails;
tableView1.DataBind();
#endregion
}
catch (Exception ex)
{
Toast(ex.Message);
}
}
/// <summary>
/// 功能:将选中的数据添加到集合里
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tableView1_CheckBox(object sender, TableViewCheckBoxCellEventArgs e)
{
string code = "";//删除的主键
TableViewRow tableViewRow = new TableViewRow();
if (e.Cell.Checked == true)
{
tableViewRow = e.Cell.OwningRow;
code = e.Cell.BindDataValue.ToString();
detList.Add(tableViewRow);
deList.Add(code);
}
else
{
detList.Remove(e.Cell.OwningRow);
deList.Remove(e.Cell.BindDataValue.ToString());
}
}
/// <summary>
/// 功能:删除表体选中的数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void delete_Press(object sender, EventArgs e)
{
//if (detList.Count < 1)
//{
// Toast("请先选择要删除的数据!");
// return;
//
//}
//for (int i = 0; i < detList.Count; i++)
//{
//
// TableViewRow tableViewRow = new TableViewRow();
// tableViewRow = detList[i];
// tableView1.Rows.Remove(tableViewRow);
//
//}
//
//detList = new List<TableViewRow>();
if (deList.Count < 1)
{
Toast("请先选择要删除的数据!");
return;
}
string whcode = "";
for (int i = 0; i < deList.Count; i++)
{
whcode += " '" + deList[i] + "'"+",";
}
if (whcode.Length > 1) {
whcode = whcode.Substring(0, whcode.Length - 1);
}
DataTable newdt = new DataTable();
newdt = dtdetails.Clone();
DataRow[] rows = dtdetails.Select(" id not in ("+ whcode + ")"); //根据选中的值重新赋值
foreach (DataRow row in rows) // 将查询的结果添加到dt中;
{
newdt.Rows.Add(row.ItemArray);
}
dtdetails = newdt;//将查询的结果添加到dtdetails中
tableView1.DataSource = newdt;
tableView1.DataBind();
deList = new List<string>();
}
/// <summary>
/// 功能:清空页面值
/// </summary>
private void RestBox()
{
txtinv.Text = "";
textBox1.Text = "";
//置空
Dictionary<string, object> data = new Dictionary<string, object>();
foreach (DataRow datarow in dtBodys.Rows)
{
data.Add(datarow["ColumnID"].ToString(), "");
}
PanelHelper.AirPanelValue(this.panel2.Controls, data);//插入panel中控件数据
tableView1.DataSource = new DataTable();
tableView1.DataBind();
}
//任务
private void button1_Press(object sender, EventArgs e)
{
if (dttask == null)
{
Toast("无任务!");
return;
}
frmProInVouchTask frmProInVouchTask = new frmProInVouchTask();
frmProInVouchTask.dttask = dttask;
this.Form.Show(frmProInVouchTask);
}
//保存
private void button2_Press(object sender, EventArgs e)
{
object dataTable= tableView1.DataSource;
dataTable = null;
//
// string errMsg = "";
// DataSet ds = new DataSet();
//
// //获取数据源
// string connectionString = NJ.UTO.WMS.Client.GlobalCom.DBConnectionStr;
// SqlConnection conn = new SqlConnection(connectionString);
//
//
// //组织表头数据
//
// conn.Open();
//
// string sql = "select * from RecordInQ where 1=0 ";
// SqlDataAdapter find = new SqlDataAdapter(sql, conn);
// DataSet dsheads = new DataSet();
//
// find.Fill(dsheads);
//
// DataTable dtheads = dsheads.Tables[0];
//
// DataRow drheads = dtheads.NewRow();
// //drheads["id"] = "";
// drheads["brdflag"] = "1";
// drheads["ccode"] = "0000000001";
// drheads["cvouchtype"] = "10";
// drheads["cwhcode"] = "";
// drheads["ddate"] = Convert.ToDateTime(Common.CuurentCommon.LoginDate.ToString("yyyy-MM-dd"));// Convert.ToDateTime(datePicker1.ToString());
// drheads["cdepcode"] = "001";
// drheads["crdcode"] = "";
// drheads["cmaker"] = Common.CuurentCommon.LoginUserName;
// drheads["cbustype"] = "成品入库";
// drheads["vt_id"] = "63";
// drheads["bisstqc"] = false;
// drheads["bpufirst"] = false;
// drheads["biafirst"] = false;
// drheads["bomfirst"] = false;
// drheads["csource"] = "库存";
// drheads["cchkcode"] = "";
// drheads["cdefine10"] = "";
// //drheads["iexchrate"] = "1";
// //drheads["cvencode"] = userTextBox2.textContent;
// //drheads["editprop"] = "A";
// dtheads.Rows.Add(drheads.ItemArray);
//
// ds.Tables.Add(dtheads.Copy());
// ds.Tables[0].TableName = "Head";
//
// conn.Close();
//
// //表体数据
// conn.Open();
// string sqls = "select * from RecordInSQ where 1=0 ";
// SqlDataAdapter finds = new SqlDataAdapter(sqls, conn);
// DataSet dsbodys = new DataSet();
//
// finds.Fill(dsbodys);
//
// DataTable dtbodys = dsbodys.Tables[0];
//
//
//
// foreach (DataRow row in dtdetails.Rows)
// {
// DataRow drbodys = dtbodys.NewRow();
// //drbodys["autoid"] = "";
// //drbodys["id"] = "";
// drbodys["cinvcode"] = row["cInvCode"].ToString();
// drbodys["inquantity"] = Convert.ToDouble(Convert.ToDecimal(row["qty"]));
// drbodys["iquantity"] = Convert.ToDouble(Convert.ToDecimal(row["qty"]));
// drbodys["brelated"] = false;
// drbodys["cposition"] = row["cPosCode"].ToString();
//
// if (row["dvdate"].ToString() != Convert.ToDateTime("1999-01-01").ToString())
// {
// drbodys["dvdate"] = DateTime.Parse(row["dvdate"].ToString());// row["BarCode"].ToString().Substring(26, 6);
// }
//
// if (row["dmdate"].ToString() != Convert.ToDateTime("1999-01-01").ToString())
// {
// drbodys["dmadedate"] = DateTime.Parse(row["dmdate"].ToString());// row["BarCode"].ToString().Substring(26, 6);
// }
//
// drbodys["cbatch"] = row["pLot"].ToString();
//
// //drbodys["editprop"] = "A";
// dtbodys.Rows.Add(drbodys.ItemArray);
// }
//
// ds.Tables.Add(dtbodys.Copy());
//
// ds.Tables[1].TableName = "Body";
//
// conn.Close();
// DataSet dsDetail = new DataSet();
// string vouchid = "";
// //保存单据ProductInOrderAdd
// //NJ.UTO.WMS.DataAccess.ProductInDA.ProductInOrderAdd(Common.CuurentCommon.SServerAddress, Common.CuurentCommon.SSubId, Common.CuurentCommon.SSerial,
// // Common.CuurentCommon.SAccID, Convert.ToDateTime(Common.CuurentCommon.LoginDate),Common.CuurentCommon.SUserID,Common.CuurentCommon.SPassword,ref vouchid,
// // false,false,false,ds,out errMsg);
//
// GlobalCom globalCom = new GlobalCom();
// globalCom.WriteLog("SUserID:" + NJ.UTO.WMS.Client.GlobalCom.SUserID + ",LoginUserName:" + NJ.UTO.WMS.Client.GlobalCom.LoginUserName
// + ",LoginString:" + NJ.UTO.WMS.Client.GlobalCom.LoginString + ",DBConnectionStr:" + NJ.UTO.WMS.Client.GlobalCom.DBConnectionStr
// + ",SAccID:" + NJ.UTO.WMS.Client.GlobalCom.SAccID + ",SYear:" + NJ.UTO.WMS.Client.GlobalCom.SYear
// + ",TaskID:" + NJ.UTO.WMS.Client.GlobalCom.TaskID, true);
//
// int result = Common.CuurentCommon.CurrentU8Service.SavePrdStockIn(ds, NJ.UTO.WMS.Client.GlobalCom.SUserID, "id", "autoid", "",
// NJ.UTO.WMS.Client.GlobalCom.SUserID, NJ.UTO.WMS.Client.GlobalCom.LoginString, NJ.UTO.WMS.Client.GlobalCom.DBConnectionStr, Convert.ToDateTime(NJ.UTO.WMS.Client.GlobalCom.SDate),
// NJ.UTO.WMS.Client.GlobalCom.SAccID, NJ.UTO.WMS.Client.GlobalCom.SYear, NJ.UTO.WMS.Client.GlobalCom.TaskID, false, false, dsDetail, NJ.UTO.WMS.Client.GlobalCom.spassword, NJ.UTO.WMS.Client.GlobalCom.sServer, out errMsg);
//
//
// if (result == 0)
// {
//
// MessageBox.Show("生单成功。");
//
// while (dtdetails.Rows.Count > 0)
// {
// dtdetails.Rows.Remove(dtdetails.Rows[0]);
// }
// tableView1.DataSource = dtdetails;
// tableView1.DataBind();
// }
// else
// {
// MessageBox.Show(errMsg);
// }
}
private void tableView1_ButtonCellPress(object sender, TableViewButtonCellEventArgs e)
{
frmProInVouchDetails frmProInVouchDetails = new frmProInVouchDetails();
this.Form.Show(frmProInVouchDetails);
}
private void popList1_Selected(object sender, EventArgs e)
{
txtinv.Text = popList1.Selection.Text;
txtinv.Tag = popList1.Selection.Value;
}
private void showpopList(DataTable dt)
{
popList1.Groups.Clear();
PopListGroup plGroup = new PopListGroup();
popList1.Groups.Add(plGroup);
popList1.Title = "存货信息";
foreach (DataRow dr in dt.Rows)
{
PopListItem popItem = new PopListItem(dr["cinvcode"].ToString(), dr["cinvname"].ToString());
plGroup.Items.Add(popItem);
}
popList1.ShowDialog();
}
} |