public static string lot_change(string lot, string domain) { string result = ""; string sql = @" exec [usp_app_JC_Apply_lot_change] '" + domain + "','" + lot + "'"; DataSet ds = SQLHelper.Query(sql, connString); string xmh = "", ljh = "", line = "", workshop = ""; DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { xmh = dt.Rows[0]["xmh"].ToString(); ljh = dt.Rows[0]["pt_desc1"].ToString(); line = dt.Rows[0]["scx"].ToString(); workshop = dt.Rows[0]["scx_workshop"].ToString(); } if (xmh == "") { DataTable ldt = new DataTable(); string sqlStr = @"select ld_part from pub.ld_det where ld_ref='{0}' and ld_qty_oh>0 with (nolock)"; sqlStr = string.Format(sqlStr, lot); ldt = QadOdbcHelper.GetODBCRows(sqlStr); if (ldt != null) { if (ldt.Rows.Count > 0) { xmh = ldt.Rows[0]["ld_part"].ToString(); } } } result = "[{\"xmh\":\"" + xmh + "\",\"ljh\":\"" + ljh + "\",\"line\":\"" + line + "\",\"workshop\":\"" + workshop + "\"}]"; return(result); }
protected void btnsave_Click(object sender, EventArgs e) { //check qad 库存 DataTable ldt = new DataTable(); string sqlStr = @"select sum(cast(cast(ld_qty_oh as numeric(18,4)) as float)) ld_qty_oh from pub.ld_det where ld_ref='{0}' and ld_domain='{1}' with (nolock)"; sqlStr = string.Format(sqlStr, workorder.Text, domain.Text); ldt = QadOdbcHelper.GetODBCRows(sqlStr); if (ldt == null) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "showsuccess", "layer.alert('单号" + workorder.Text + ",QAD库存不存在');", true); return; } if (ldt.Rows.Count <= 0) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "showsuccess", "layer.alert('单号" + workorder.Text + ",QAD库存不存在');", true); return; } if (ldt.Rows[0]["ld_qty_oh"].ToString() != act_qty.Text) { ScriptManager.RegisterStartupScript(Page, this.GetType() , "showsuccess", "layer.alert('单号" + workorder.Text + ",库存不一致.QAD库存" + ldt.Rows[0]["ld_qty_oh"].ToString() + "当前待入库" + act_qty.Text + "');" , true); return; } string re_sql = re_sql = @"exec usp_app_Ruku_bcp_hege '{0}', '{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}'"; re_sql = string.Format(re_sql, emp_code_name.Text, workorder.Text, domain.Text, pgino.Text, pn.Text, qty.Text, act_qty.Text, comment.Value, loc_hg.Text); DataTable re_dt = SQLHelper.Query(re_sql).Tables[0]; string flag = re_dt.Rows[0][0].ToString(); string msg = re_dt.Rows[0][1].ToString(); if (flag == "N") { string url = ""; if (_dh != "") { if (_ck == "N")//车间的 { url = "/Cjgl1.aspx?workshop=" + _workshop; } if (_ck == "Y")//仓库的 { url = "/ck.aspx"; } } ScriptManager.RegisterStartupScript(Page, this.GetType(), "showsuccess" , "$.toptip('入库成功', 2000, 'success');var int = self.setTimeout(function(){ self.location='" + url + "' }, 2000); " , true); return; } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "showsuccess", "layer.alert('失败:" + msg + "');", true); return; } }
void init_data(string formno, string stepid) { string sql = @"exec [usp_app_Adjust_Apply_init_V1] '{0}','{1}'"; sql = string.Format(sql, formno, stepid); DataSet ds = SQLHelper.Query(sql); DataTable dt = ds.Tables[0]; if (dt.Rows.Count == 1) { emp_code_name_db.Text = dt.Rows[0]["emp_code"].ToString() + dt.Rows[0]["emp_name"].ToString(); source.Text = dt.Rows[0]["source"].ToString(); dh.Text = dt.Rows[0]["lot_no"].ToString(); pgino.Text = dt.Rows[0]["pgino"].ToString(); pn.Text = dt.Rows[0]["pn"].ToString(); from_qty_db.Text = "原数量" + dt.Rows[0]["from_qty"].ToString(); from_qty_db.Visible = true; adj_qty.Text = dt.Rows[0]["adj_qty"].ToString(); comment.Value = dt.Rows[0]["remark"].ToString(); //改三个字段proc重新复制喽 if (dt.Rows[0]["flagwhere"].ToString() != "QAD") { from_qty.Text = dt.Rows[0]["from_qty_cur"].ToString(); need_no.Text = dt.Rows[0]["need_no"].ToString(); flagwhere.Text = dt.Rows[0]["flagwhere"].ToString(); loc.Text = dt.Rows[0]["loc"].ToString(); } else { DataTable ldt = new DataTable(); string sqlStr = @"select ld_part,ld_loc,cast(cast(ld_qty_oh as numeric(18,4)) as float) ld_qty_oh from pub.ld_det where ld_ref='{0}' and ld_domain='200' and ld_loc='{1}' with (nolock)"; sqlStr = string.Format(sqlStr, dt.Rows[0]["lot_no"].ToString(), dt.Rows[0]["loc"].ToString()); ldt = QadOdbcHelper.GetODBCRows(sqlStr); if (ldt == null) { } else if (ldt.Rows.Count <= 0) { } else//QAD存在 { from_qty.Text = ldt.Rows[0]["ld_qty_oh"].ToString(); flagwhere.Text = "QAD"; need_no.Text = ""; loc.Text = ldt.Rows[0]["ld_loc"].ToString(); } } } DataTable dt_sg = ds.Tables[1]; Repeater_sg.DataSource = dt_sg; Repeater_sg.DataBind(); }
public static string ref_order_change(string domain, string ref_order, string pgino, string op) { string flag = "N", msg = "", qty = "", workorder_qc_loc = ""; //check qad 库存 DataTable ldt = new DataTable(); string sqlStr = @"select ld_part,cast(cast(ld_qty_oh as numeric(18,4)) as float) ld_qty_oh,ld_loc from pub.ld_det where ld_ref='{0}' and ld_domain='{1}' and ld_qty_oh>0 with (nolock)"; sqlStr = string.Format(sqlStr, ref_order, domain); ldt = QadOdbcHelper.GetODBCRows(sqlStr); if (ldt == null) { flag = "Y"; msg = "参考号" + ref_order + ",QAD库存不存在"; } else if (ldt.Rows.Count <= 0) { flag = "Y"; msg = "参考号" + ref_order + ",QAD库存不存在"; } else if (ldt.Rows.Count > 1) { flag = "Y"; msg = "参考号" + ref_order + ",QAD多笔库存"; } else { if (ldt.Rows[0]["ld_part"].ToString() != pgino) { flag = "Y"; msg = "物料号不一致.参考号" + ref_order + "对应的物料号" + ldt.Rows[0]["ld_part"].ToString() + ",当前申请物料号" + pgino; } else if (op == "997" && ldt.Rows[0]["ld_loc"].ToString() != "2002") { flag = "Y"; msg = "参考号" + ref_order + "当前库位不是2002,请联系仓库."; } else if (op == "998" && ldt.Rows[0]["ld_loc"].ToString() != "4002") { flag = "Y"; msg = "参考号" + ref_order + "当前库位不是4002,请联系仓库."; } else if (op == "999" && ldt.Rows[0]["ld_loc"].ToString() != "9002") { flag = "Y"; msg = "参考号" + ref_order + "当前库位不是9002,请联系仓库."; } else { qty = ldt.Rows[0]["ld_qty_oh"].ToString(); workorder_qc_loc = ldt.Rows[0]["ld_loc"].ToString(); } } string result = "[{\"flag\":\"" + flag + "\",\"msg\":\"" + msg + "\",\"qty\":\"" + qty + "\",\"workorder_qc_loc\":\"" + workorder_qc_loc + "\"}]"; return(result); }
public static string sure2(string _emp_code_name, string need_no, string lotno, string act_qty, string pgino, string pn , string comment, string loc_from, string loc_to, string sku_area, string pgino_yn) { string flag = "N", msg = ""; //判断是否是数据库第一笔数据 if (pgino_yn == "Y") { if (loc_from != loc_to) { DataTable ldt = new DataTable(); string sqlStr = @"select top 1 ld_ref,ld_loc,ld_qty_oh from pub.ld_det where ld_status in('FG-ZONE','RM-ZONE') and ld_part='{0}' and ld_qty_oh>0 order by ld_date,ld_ref with (nolock)"; sqlStr = string.Format(sqlStr, pgino); ldt = QadOdbcHelper.GetODBCRows(sqlStr); if (ldt.Rows.Count <= 0) { flag = "Y"; msg = "QAD没有可移到线边库的Lot No"; } else { if (ldt.Rows[0]["ld_ref"].ToString() == lotno) { //验证高架库位及数量是否相等 if (ldt.Rows[0]["ld_loc"].ToString() != loc_from) { flag = "Y"; msg = "库位不一致,QAD:" + ldt.Rows[0]["ld_loc"].ToString() + "当前:" + loc_from; } if ((Convert.ToSingle(ldt.Rows[0]["ld_qty_oh"].ToString())).ToString() != act_qty) { flag = "Y"; msg = "数量不相等,QAD:" + (Convert.ToSingle(ldt.Rows[0]["ld_qty_oh"].ToString())).ToString() + "当前:" + act_qty; } } else//提示出来,询问是否继续送料 { flag = "Y_S"; msg = "QAD第一笔Lot No" + ldt.Rows[0]["ld_loc"].ToString() + ",当前:" + lotno; } } } } string result = "[{\"flag\":\"" + flag + "\",\"msg\":\"" + msg + "\"}]"; return(result); }
public static string sure2(string _emp_code_name, string _formno, string _stepid, string _sign_comment , string _lot_no, string _source, string _flagwhere, string _loc, string _adj_qty_abs, string _from_qty) { string flag = "N", msg = ""; string from_qty_cur = _from_qty; if (_flagwhere == "QAD") { if ((_stepid == "0002" && Convert.ToSingle(_adj_qty_abs) <= 2) || _stepid == "0003")//签核完成才调用 { DataTable ldt = new DataTable(); string sqlStr = @"select ld_part,ld_loc,cast(cast(ld_qty_oh as numeric(18,4)) as float) ld_qty_oh from pub.ld_det where ld_ref='{0}' and ld_domain='200' and ld_loc='{1}' with (nolock)"; sqlStr = string.Format(sqlStr, _lot_no, _loc); ldt = QadOdbcHelper.GetODBCRows(sqlStr); if (ldt == null) { } else if (ldt.Rows.Count <= 0) { } else//QAD存在 { from_qty_cur = ldt.Rows[0]["ld_qty_oh"].ToString(); } } } string re_sql = @"exec [usp_app_Adjust_sign] '{0}','{1}','{2}','{3}','{4}'"; re_sql = string.Format(re_sql, _emp_code_name, _formno, _stepid, _sign_comment, from_qty_cur); DataTable re_dt = SQLHelper.Query(re_sql).Tables[0]; flag = re_dt.Rows[0][0].ToString(); msg = re_dt.Rows[0][1].ToString(); string result = "[{\"flag\":\"" + flag + "\",\"msg\":\"" + msg + "\"}]"; return(result); }
public static string save2(string _dh, float _curr_qty, string _emp, string _pgino, string _btnms , string _dh_record, string _remark, string _stepvalue) { string flag = "N", msg = "", re_sql = "", _dh_source = "", _ref = "", _rk_dh = "", _loc = "", _tx = "";; if (_dh_record.Contains(",")) { _dh_source = _dh_record.Substring(1, _dh_record.Length - 1); } string sql_dh = "select top 1 1 from Mes_App_WorkOrder_hege where workorder='{0}' and right(routing,1)='R' "; sql_dh = string.Format(sql_dh, _dh); DataTable dt_dh = SQLHelper.Query(sql_dh).Tables[0]; if (dt_dh.Rows.Count > 0) { _tx = "挑选"; } string sql = "select dh from Mes_APP_WorkOrder_CKSH_Hege where workorder='{0}' and ISNULL(is_yn,'')='' "; sql = string.Format(sql, _dh_source); DataTable dt = SQLHelper.Query(sql).Tables[0]; if (dt.Rows.Count > 0) { _rk_dh = dt.Rows[0][0].ToString(); // _ref= dt.Rows[0][0].ToString(); } //else //{ // _ref = _dh_source; //} _ref = _dh_source; if (_tx != "") { DataTable ldt = new DataTable(); string sqlStr = @"select ld_loc from pub.ld_det where ld_ref='{0}' with (nolock)"; sqlStr = string.Format(sqlStr, _ref); ldt = QadOdbcHelper.GetODBCRows(sqlStr); if (ldt != null) { if (ldt.Rows.Count > 0) { _loc = ldt.Rows[0]["ld_loc"].ToString(); } } } if (_curr_qty <= 0) { re_sql = @"exec usp_app_qc_recover '{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}'"; } else { re_sql = @"exec usp_app_qc_Insert_V1 '{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}'"; } if (flag == "N") { re_sql = string.Format(re_sql, _dh, _curr_qty, _emp, _pgino, _btnms, _dh_source, _remark, _stepvalue, _rk_dh, _loc, _ref); DataTable re_dt = SQLHelper.Query(re_sql).Tables[0]; flag = re_dt.Rows[0][0].ToString(); msg = re_dt.Rows[0][1].ToString(); } string result = "[{\"flag\":\"" + flag + "\",\"msg\":\"" + msg + "\"}]"; return(result); }
public static string reason_change(string workorder, string ruku_dh, string reason) { string flag = "N", msg = "", qty = ""; string re_sql = @"exec [usp_app_Chuku_reason_change_V1] '{0}','{1}','{2}'"; re_sql = string.Format(re_sql, workorder, ruku_dh, reason); DataSet ds = SQLHelper.Query(re_sql); DataTable re_dt = ds.Tables[0]; flag = re_dt.Rows[0][0].ToString(); msg = re_dt.Rows[0][1].ToString(); if (flag == "N") { string ld_ref = ""; if (reason == "成品领用")//form_dh { if (ruku_dh == "") { ld_ref = workorder; } else { ld_ref = ruku_dh; } } else if (reason == "零箱返线") { ld_ref = ruku_dh; } DataTable ldt = new DataTable(); string sqlStr = @"select ld_date,cast(cast(ld_qty_oh as numeric(18,4)) as float) ld_qty_oh from pub.ld_det where ld_ref='{0}' with (nolock)"; sqlStr = string.Format(sqlStr, ld_ref); ldt = QadOdbcHelper.GetODBCRows(sqlStr); if (ldt == null) { flag = "Y"; msg = "参考号" + ld_ref + ",QAD不存在"; } else if (ldt.Rows.Count <= 0) { flag = "Y"; msg = "参考号" + ld_ref + ",QAD不存在"; } else if (ldt.Rows.Count > 1) { flag = "Y"; msg = "参考号" + ld_ref + ",QAD存在多笔."; } else { string ld_date = ldt.Rows[0]["ld_date"].ToString(); float ld_qty_oh = Convert.ToSingle(ldt.Rows[0]["ld_qty_oh"].ToString()); string re_sql_q = @"exec [usp_app_Chuku_reason_change_qty] '{0}','{1}','{2}','{3}',{4}"; re_sql_q = string.Format(re_sql_q, workorder, ruku_dh, reason, ld_date, ld_qty_oh); DataSet ds_q = SQLHelper.Query(re_sql_q); DataTable re_dt_q = ds_q.Tables[0]; flag = re_dt_q.Rows[0][0].ToString(); msg = re_dt_q.Rows[0][1].ToString(); if (flag == "N") { qty = re_dt_q.Rows[0]["qty"].ToString(); } } } string result = "[{\"flag\":\"" + flag + "\",\"msg\":\"" + msg + "\",\"qty\":\"" + qty + "\"}]"; return(result); }
protected void btnsave_Click(object sender, EventArgs e) { string form_dh = "", loc = ""; if (reason.Text == "成品领用")//form_dh { if (ruku_dh.Text == "") { form_dh = workorder.Text; } else { form_dh = ruku_dh.Text; } } //qad 库位 if (reason.Text == "成品领用" || reason.Text == "零箱返线") { string ld_ref = ""; if (reason.Text == "成品领用") { ld_ref = form_dh; } else if (reason.Text == "零箱返线") { ld_ref = ruku_dh.Text; } DataTable ldt = new DataTable(); string sqlStr = @"select ld_loc from pub.ld_det where ld_ref='{0}' with (nolock)"; sqlStr = string.Format(sqlStr, ld_ref); ldt = QadOdbcHelper.GetODBCRows(sqlStr); if (ldt == null) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "showsuccess", "layer.alert('参考号" + ld_ref + ",QAD不存在');", true); return; } if (ldt.Rows.Count <= 0) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "showsuccess", "layer.alert('参考号" + ld_ref + ",QAD不存在');", true); return; } loc = ldt.Rows[0]["ld_loc"].ToString(); } string re_sql = re_sql = @"exec usp_app_Chuku '{0}', '{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}'"; re_sql = string.Format(re_sql, emp_code_name.Text, workorder.Text, ruku_dh.Text, domain.Text, pgino.Text, pn.Text, qty.Text, act_qty.Text, comment.Value, reason.Text, form_dh, loc); DataTable re_dt = SQLHelper.Query(re_sql).Tables[0]; string flag = re_dt.Rows[0][0].ToString(); string msg = re_dt.Rows[0][1].ToString(); if (flag == "N") { string url = "/ck.aspx"; //ScriptManager.RegisterStartupScript(Page, this.GetType(), "showsuccess" // , "layer.alert('出库成功,出库单号" + msg + "', {}, function (index) {window.location.href='" + url + "'; }); " // , true); ScriptManager.RegisterStartupScript(Page, this.GetType(), "showsuccess" , "layer.alert('" + msg + "', {}, function (index) {window.location.href='" + url + "'; }); " , true); return; } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "showsuccess", "layer.alert('失败:" + msg + "');", true); return; } }
public static string lotno_change(string pgino, string lotno, string need_no, string domain) { string re_sql = @"exec [usp_app_SL_lot_change_qad_V1] '{0}', '{1}', '{2}'"; re_sql = string.Format(re_sql, pgino, lotno, need_no); DataSet ds = SQLHelper.Query(re_sql); DataTable re_dt = ds.Tables[0]; string flag = re_dt.Rows[0][0].ToString(); string msg = re_dt.Rows[0][1].ToString(); string qty = "", loc_from = "", loc_to = "", pgino_yn = ""; if (flag == "N") { DataTable dt = ds.Tables[1]; loc_to = dt.Rows[0][0].ToString(); pgino_yn = ds.Tables[2].Rows[0][0].ToString(); DataTable ldt = new DataTable(); string sqlStr = ""; string ldt_source = ""; if (pgino_yn == "Y") { sqlStr = @"select ld_loc,ld_qty_oh from pub.ld_det where ld_status in('FG-ZONE','RM-ZONE') and ld_part='{0}' and ld_ref='{1}' and ld_qty_oh>0 with (nolock)"; sqlStr = string.Format(sqlStr, pgino, lotno); ldt = QadOdbcHelper.GetODBCRows(sqlStr); ldt_source = "1"; } //1,未获取到高架库位的参考号,需要继续获取线边库的 2,直接需要获取线边库的参考号 if (ldt.Rows.Count == 0) { //sqlStr = @"select ld_loc,ld_qty_oh from pub.ld_det where ld_status='WIP' and ld_part='" + pgino + "' and ld_ref='" + lotno + "' and ld_loc='" + loc_to + "' with (nolock)"; sqlStr = @"select ld_loc,ld_qty_oh,ld_part,ld_status from pub.ld_det where ld_ref='" + lotno + "' and ld_qty_oh>0 with (nolock)"; ldt = QadOdbcHelper.GetODBCRows(sqlStr); ldt_source = "2"; } if (ldt == null) { flag = "Y"; msg = "Lot No:" + lotno + "不存在"; } else if (ldt.Rows.Count <= 0) { flag = "Y"; msg = "Lot No:" + lotno + "不存在"; } else { if (ldt_source == "1") { flag = "N"; msg = ""; } else if (ldt_source == "2") { if (ldt.Rows[0]["ld_part"].ToString() != pgino) { flag = "Y"; msg = "物料号不一致.QAD物料号:" + ldt.Rows[0]["ld_part"].ToString() + " 当前物料号:" + pgino; } else if (ldt.Rows[0]["ld_loc"].ToString() != loc_to) { flag = "Y"; msg = "库位不一致.QAD库位:" + ldt.Rows[0]["ld_loc"].ToString() + " 当前库位:" + loc_to; } else if (ldt.Rows[0]["ld_status"].ToString().ToUpper() != "WIP") { flag = "Y"; msg = "QAD状态不是WIP.当前QAD状态:" + ldt.Rows[0]["ld_status"].ToString(); } else { flag = "N"; msg = ""; } } } if (flag == "N") { loc_from = ldt.Rows[0]["ld_loc"].ToString(); float qty_c = Convert.ToSingle(ldt.Rows[0]["ld_qty_oh"].ToString()); string sql_q = @"exec [usp_app_SL_lot_change_qad_qty] '{0}', '{1}', {2}, '{3}', '{4}'"; sql_q = string.Format(sql_q, pgino, lotno, qty_c, need_no, domain); DataTable re_dt_q = SQLHelper.Query(sql_q).Tables[0]; flag = re_dt_q.Rows[0][0].ToString(); msg = re_dt_q.Rows[0][1].ToString(); if (flag == "N") { qty = qty_c.ToString(); } } } string result = "[{\"flag\":\"" + flag + "\",\"msg\":\"" + msg + "\",\"qty\":\"" + qty + "\",\"loc_from\":\"" + loc_from + "\",\"loc_to\":\"" + loc_to + "\",\"pgino_yn\":\"" + pgino_yn + "\"}]"; return(result); }
protected void lk_lotno_qad_Click(object sender, EventArgs e) { if (listBx_lotno_qad.Visible == true) { listBx_lotno_qad.Visible = false; return; } else { listBx_lotno_qad.Visible = true; } DataTable ldt = new DataTable(); //送料信息里,第一笔 绑定库存明细里的 string sqlStr = @"select top 2 ld_part,ld_ref,ld_loc,cast(cast(ld_qty_oh as numeric(18,4)) as float) ld_qty_oh from pub.ld_det where ld_status in('FG-ZONE','RM-ZONE') and ld_part='{0}' and ld_qty_oh>0 order by ld_date,ld_ref with (nolock)"; sqlStr = string.Format(sqlStr, pgino.Text); ldt = QadOdbcHelper.GetODBCRows(sqlStr); string flag = "N"; string msg = ""; if (ldt.Rows.Count <= 0) { flag = "Y"; msg = "没有符合条件的Lot No"; } if (flag == "Y") { ScriptManager.RegisterStartupScript(Page, this.GetType(), "showsuccess", "$.toptip('没有符合条件的Lot No', 'warning');", true); return; } string re_sql = @"exec [usp_app_SL_lot_change_loc] '{0}'"; re_sql = string.Format(re_sql, pgino.Text); DataSet ds = SQLHelper.Query(re_sql); DataTable re_dt = ds.Tables[0]; flag = re_dt.Rows[0][0].ToString(); msg = re_dt.Rows[0][1].ToString(); if (flag == "Y") { ScriptManager.RegisterStartupScript(Page, this.GetType(), "showsuccess", "$.toptip('" + msg + "', 'warning');", true); return; } DataTable dt = ds.Tables[1]; string loc_to = dt.Rows[0][0].ToString(); ldt.Columns.Add("sku_area", typeof(string)); ldt.Columns.Add("loc_to", typeof(string)); foreach (DataRow row in ldt.Rows) { row["sku_area"] = sku_area.Text; row["loc_to"] = loc_to; } listBx_lotno_qad.DataSource = ldt; listBx_lotno_qad.DataBind(); }
public static string save2(string _emp_code_name, string _source, string _dh, string _pgino, string _pn, string _from_qty , string _adj_qty, string _comment, string _flagwhere, string _need_no, string _formno, string _stepid, string _loc) { string flag = "N", msg = ""; string re_sql = "", flagw = ""; if (_flagwhere != "QAD") { if (_flagwhere == "QAD_W")//QAD里的车间数据,需要补WIP表数据 { string sql_n = @"exec usp_app_Adjust_Apply_HY '{0}','{1}','{2}','{3}'"; sql_n = string.Format(sql_n, _emp_code_name, _dh, _need_no, _source); DataTable dt_n = SQLHelper.Query(sql_n).Tables[0]; flag = dt_n.Rows[0][0].ToString(); msg = dt_n.Rows[0][1].ToString(); if (flag == "N") { flagw = _flagwhere; _flagwhere = "已生产"; } } re_sql = @"exec usp_app_Adjust_Apply '{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}'"; } else { DataTable ldt = new DataTable(); string sqlStr = @"select ld_part,ld_loc,cast(cast(ld_qty_oh as numeric(18,4)) as float) ld_qty_oh from pub.ld_det where ld_ref='{0}' and ld_domain='200' and ld_loc='{1}' with (nolock)"; sqlStr = string.Format(sqlStr, _dh, _loc); ldt = QadOdbcHelper.GetODBCRows(sqlStr); if (ldt == null) { flag = "Y"; msg = "单号:" + _dh + ",地点:" + _source + ",QAD不存在.请重新打开页面申请."; } else if (ldt.Rows.Count <= 0) { flag = "Y"; msg = "单号:" + _dh + ",地点:" + _source + ",QAD不存在.请重新打开页面申请."; } else//QAD存在 { if (_from_qty != ldt.Rows[0]["ld_qty_oh"].ToString()) { flag = "Y"; msg = "单号:" + _dh + ",地点:" + _source + ",QAD【数量】发生异动.请重新打开页面申请."; } else { re_sql = @"exec usp_app_Adjust_Apply_QAD '{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}'"; } } } if (flag == "N") { re_sql = string.Format(re_sql, _emp_code_name, _source, _dh, _pgino, _pn, _from_qty, _adj_qty , _comment, _flagwhere, _need_no, _formno, _stepid, _loc, flagw); DataTable re_dt = SQLHelper.Query(re_sql).Tables[0]; flag = re_dt.Rows[0][0].ToString(); msg = re_dt.Rows[0][1].ToString(); } string result = "[{\"flag\":\"" + flag + "\",\"msg\":\"" + msg + "\"}]"; return(result); }
public static string dh_change(string dh, string source) { string flag = "N", msg = ""; string pgino = "", pn = "", from_qty = "", flagwhere = "", need_no = "", loc = ""; #region 车间 if (source == "二车间" || source == "三车间" || source == "四车间") { string re_sql = @"exec [usp_app_Adjust_Apply_dh_change_V1] '{0}','{1}'"; re_sql = string.Format(re_sql, dh, source); DataSet ds = SQLHelper.Query(re_sql); DataTable dt_r = ds.Tables[0]; flag = dt_r.Rows[0][0].ToString(); msg = dt_r.Rows[0][1].ToString(); if (flag == "N") { DataTable re_dt = ds.Tables[1]; pgino = re_dt.Rows[0]["pgino"].ToString(); pn = re_dt.Rows[0]["pn"].ToString(); from_qty = re_dt.Rows[0]["from_qty"].ToString(); flagwhere = re_dt.Rows[0]["flagwhere"].ToString(); need_no = re_dt.Rows[0]["need_no"].ToString(); } if (flag == "Y1") { if (dt_r.Rows[0]["need_no"].ToString() == "" && (source == "二车间" || source == "四车间")) { flag = "Y"; msg = msg + ",且没有上料记录"; } //else if (dt_r.Rows[0]["from_qty"].ToString() == "0") //{ // flag = "Y"; msg = ",在制数量不为0"; //} else { //再次判断是否是QAD的参考号 DataTable ldt = new DataTable(); string sqlStr = @"select ld_part,ld_loc,ld_status,cast(cast(ld_qty_oh as numeric(18,4)) as float) ld_qty_oh from pub.ld_det where ld_ref='{0}' and ld_domain='200' with (nolock)"; sqlStr = string.Format(sqlStr, dh); ldt = QadOdbcHelper.GetODBCRows(sqlStr); if (ldt == null) { flag = "Y"; msg = msg + "/QAD"; } else if (ldt.Rows.Count <= 0) { flag = "Y"; msg = msg + "/QAD"; } else//QAD存在 { //零件号 string sql_s = @"select pt_desc1,pt_prod_line from [172.16.5.26].qad.dbo.qad_pt_mstr where pt_part='" + ldt.Rows[0]["ld_part"].ToString() + "' and pt_domain='200'"; DataTable dt_s = SQLHelper.Query(sql_s).Tables[0]; if (dt_s == null) { flag = "Y"; msg = "物料号" + ldt.Rows[0]["ld_part"].ToString() + ",对应的零件号不存在"; } else if (dt_s.Rows.Count <= 0) { flag = "Y"; msg = "物料号" + ldt.Rows[0]["ld_part"].ToString() + "对应的零件号不存在"; } else//QAD存在 { pn = dt_s.Rows[0]["pt_desc1"].ToString(); if (source == "二车间" || source == "四车间") { if (ldt.Rows[0]["ld_loc"].ToString() != "9000" && ldt.Rows[0]["ld_status"].ToString().ToUpper() != "WIP") { flag = "Y"; msg = "单号" + dh + ",库位不是9000、状态WIP"; } } if (source == "三车间") { if (dt_s.Rows[0]["pt_prod_line"].ToString().StartsWith("3")) { if (ldt.Select("ld_loc='9000'").Length != 1)//if (ldt.Rows[0]["ld_loc"].ToString() != "9000") { flag = "Y"; msg = "单号" + dh + ",库位不是9000"; } } if (dt_s.Rows[0]["pt_prod_line"].ToString().StartsWith("2")) { if (ldt.Select("ld_loc='4009'").Length != 1)//if (ldt.Rows[0]["ld_loc"].ToString() != "4009") { flag = "Y"; msg = "单号" + dh + ",库位不是4009"; } } } if (flag == "Y1") { if (source == "二车间" || source == "四车间") { if (ldt.Rows[0]["ld_qty_oh"].ToString() != dt_r.Rows[0]["from_qty"].ToString()) { flag = "Y"; msg = "单号" + dh + ",APP在制数量" + dt_r.Rows[0]["from_qty"].ToString() + ",QAD数量" + ldt.Rows[0]["ld_qty_oh"].ToString() + "不一致,不能申请."; } else { flag = "N"; msg = ""; pgino = ldt.Rows[0]["ld_part"].ToString(); loc = ldt.Rows[0]["ld_loc"].ToString(); //取当前APP里的数据 from_qty = dt_r.Rows[0]["from_qty"].ToString(); flagwhere = "QAD_W"; need_no = dt_r.Rows[0]["need_no"].ToString(); } } if (source == "三车间") { flag = "N"; msg = ""; //pgino = ldt.Rows[0]["ld_part"].ToString(); //loc = ldt.Rows[0]["ld_loc"].ToString(); //from_qty = ldt.Rows[0]["ld_qty_oh"].ToString(); flagwhere = "QAD"; need_no = ""; DataRow[] drs = null; if (dt_s.Rows[0]["pt_prod_line"].ToString().StartsWith("3")) { drs = ldt.Select("ld_loc='9000'"); } if (dt_s.Rows[0]["pt_prod_line"].ToString().StartsWith("2")) { drs = ldt.Select("ld_loc='4009'"); } pgino = drs[0]["ld_part"].ToString(); loc = drs[0]["ld_loc"].ToString(); from_qty = drs[0]["ld_qty_oh"].ToString(); } } } } } } } #endregion #region 库内 if (source == "原材料库" || source == "成品库" || source == "半成品库") { //再次判断是否是QAD的参考号 DataTable ldt = new DataTable(); string sqlStr = @"select ld_part,ld_loc,ld_status,cast(cast(ld_qty_oh as numeric(18,4)) as float) ld_qty_oh from pub.ld_det where ld_ref='{0}' and ld_domain='200' with (nolock)"; sqlStr = string.Format(sqlStr, dh); ldt = QadOdbcHelper.GetODBCRows(sqlStr); if (ldt == null) { flag = "Y"; msg = "单号:" + dh + ",地点:" + source + ",不存在QAD"; } else if (ldt.Rows.Count <= 0) { flag = "Y"; msg = "单号:" + dh + ",地点:" + source + ",不存在QAD"; } else//QAD存在 { //零件号 string sql_s = @"select pt_desc1,pt_prod_line from [172.16.5.26].qad.dbo.qad_pt_mstr where pt_part='" + ldt.Rows[0]["ld_part"].ToString() + "' and pt_domain='200'"; DataTable dt_s = SQLHelper.Query(sql_s).Tables[0]; if (dt_s == null) { flag = "Y"; msg = "物料号" + ldt.Rows[0]["ld_part"].ToString() + ",对应的零件号不存在"; } else if (dt_s.Rows.Count <= 0) { flag = "Y"; msg = "物料号" + ldt.Rows[0]["ld_part"].ToString() + "对应的零件号不存在"; } else//QAD存在 { pn = dt_s.Rows[0]["pt_desc1"].ToString(); if (source == "原材料库") { if (dt_s.Rows[0]["pt_prod_line"].ToString().StartsWith("1") == false) { flag = "Y"; msg = "物料号" + ldt.Rows[0]["ld_part"].ToString() + "不是原材料,不能选择【原材料库】."; } } if (source == "半成品库") { if (dt_s.Rows[0]["pt_prod_line"].ToString().StartsWith("2") == false) { flag = "Y"; msg = "物料号" + ldt.Rows[0]["ld_part"].ToString() + "不是半成品,不能选择【半成品库】."; } } if (source == "成品库") { if (dt_s.Rows[0]["pt_prod_line"].ToString().StartsWith("3") == false) { flag = "Y"; msg = "物料号" + ldt.Rows[0]["ld_part"].ToString() + "不是成品,不能选择【成品库】."; } } if (flag == "N") { flag = "N"; msg = ""; pgino = ldt.Rows[0]["ld_part"].ToString(); from_qty = ldt.Rows[0]["ld_qty_oh"].ToString(); flagwhere = "QAD"; need_no = ""; loc = ldt.Rows[0]["ld_loc"].ToString(); } } } } #endregion string result = "[{\"flag\":\"" + flag + "\",\"msg\":\"" + msg + "\",\"pgino\":\"" + pgino + "\",\"pn\":\"" + pn + "\",\"from_qty\":\"" + from_qty + "\",\"flagwhere\":\"" + flagwhere + "\",\"need_no\":\"" + need_no + "\",\"loc\":\"" + loc + "\"}]"; return(result); }
public static string pgino_change(string domain, string pgino, string _ref, string loc) { string result = ""; string msg = ""; string xmh_value = "", ref_value = "", loc_value = "", qty_value = ""; if (pgino == "") { msg = "请先输入物料号"; } if (msg == "") { string sql = @" exec [usp_app_Loc_Transfer_init_data_js] '" + domain + "','','" + pgino + "'"; DataTable dt_pgino = SQLHelper.Query(sql).Tables[0]; if (dt_pgino.Rows.Count <= 0) { msg = "物料号" + pgino + "不存在"; } if (msg == "") { xmh_value = dt_pgino.Rows[0]["title"].ToString(); DataTable ldt = new DataTable(); string sqlStr = "select ld_ref,cast(ld_qty_oh as float)ld_qty_oh,ld_loc from pub.ld_det where ld_domain='{0}' and ld_part='{1}' and ld_qty_oh>0 with (nolock)"; sqlStr = string.Format(sqlStr, domain, xmh_value); ldt = QadOdbcHelper.GetODBCRows(sqlStr); if (ldt == null) { msg = "项目号" + xmh_value + ",QAD库存不存在"; } else { if (ldt.Rows.Count <= 0) { msg = "项目号" + xmh_value + ",QAD库存不存在"; } } if (msg == "") { DataRow[] drs = null; if (_ref != "" && loc == "") { drs = ldt.Select("ld_ref='" + _ref + "'"); if (drs.Length <= 0) { msg = "项目号" + xmh_value + ",参考号" + _ref + ",QAD库存不存在"; } } else if (_ref == "" && loc != "") { drs = ldt.Select("ld_loc='" + loc + "' and ld_ref=''"); if (drs.Length <= 0) { msg = "项目号" + xmh_value + ",当前库位" + loc + ",QAD库存不存在"; } else if (drs.Length > 1) { msg = "项目号" + xmh_value + ",当前库位" + loc + ",QAD库存存在多笔"; } } else if (_ref != "" && loc != "") { drs = ldt.Select("ld_ref='" + _ref + "' and ld_loc='" + loc + "'"); if (drs.Length <= 0) { msg = "项目号" + xmh_value + ",参考号" + _ref + ",当前库位" + loc + ",QAD库存不存在"; } else if (drs.Length > 1) { msg = "项目号" + xmh_value + ",参考号" + _ref + ",当前库位" + loc + ",QAD库存存在多笔"; } } if (msg == "" && drs != null) { if (drs.Length == 1)//多笔的 不自动带出 { ref_value = drs[0]["ld_ref"].ToString(); qty_value = drs[0]["ld_qty_oh"].ToString(); loc_value = drs[0]["ld_loc"].ToString(); } } } } } result = "[{\"msg\":\"" + msg + "\",\"xmh_value\":\"" + xmh_value + "\",\"ref_value\":\"" + ref_value + "\",\"loc_value\":\"" + loc_value + "\",\"qty_value\":\"" + qty_value + "\"}]"; return(result); }
public static string pgino_change(string pgino, string domain) { string re_sql = @"exec [usp_app_YL_pgino_change] '{0}','{1}'"; re_sql = string.Format(re_sql, pgino, domain); DataSet ds = SQLHelper.Query(re_sql); DataTable re_dt = ds.Tables[0]; string flag = re_dt.Rows[0][0].ToString(); string msg = re_dt.Rows[0][1].ToString(); string pn = "", descr = "", qty = "", pt_prod_line = ""; if (flag == "N") { DataTable dt = ds.Tables[1]; pn = dt.Rows[0]["pt_desc1"].ToString(); descr = dt.Rows[0]["pt_desc2"].ToString(); qty = dt.Rows[0]["pt_ord_mult"].ToString(); pt_prod_line = dt.Rows[0]["pt_prod_line"].ToString(); } string ld_ref = "", ld_qty_oh = ""; DataTable ldt = new DataTable(); /* * string sqlStr = @"";//送料信息里,第一笔 绑定库存明细里的 * if (pt_prod_line != "1090") * { * sqlStr = @"select top 1 ld_part,ld_ref,ld_loc,cast(cast(ld_qty_oh as numeric(18,4)) as float) ld_qty_oh from pub.ld_det * where ld_status in('FG-ZONE','RM-ZONE') and ld_part='{0}' and ld_qty_oh>0 * order by ld_date,ld_ref * with (nolock)"; * } * else * { * sqlStr = @"select top 1 ld_part,ld_ref,ld_loc,cast(cast(ld_qty_oh as numeric(18,4)) as float) ld_qty_oh from pub.ld_det * where ld_status in('FG-ZONE','RM-ZONE') and ld_part='{0}' and ld_qty_oh>0 * order by ld_date,ld_ref,ld_qty_oh * with (nolock)"; * } * sqlStr = string.Format(sqlStr, pgino); * ldt = QadOdbcHelper.GetODBCRows(sqlStr); * if (ldt.Rows.Count > 0) * { * ld_ref = ldt.Rows[0]["ld_ref"].ToString(); * ld_qty_oh = ldt.Rows[0]["ld_qty_oh"].ToString(); * } */ string sqlStr = @"select ld_ref title,cast(cast(ld_qty_oh as numeric(18,4)) as float) value from pub.ld_det where ld_status in('FG-ZONE','RM-ZONE') and ld_part='{0}' and ld_qty_oh>0"; if (pt_prod_line != "1090") { sqlStr = sqlStr + @" order by ld_date,ld_ref"; } else { sqlStr = sqlStr + @" order by ld_date,ld_ref,ld_qty_oh"; } sqlStr = sqlStr + @" with (nolock)"; sqlStr = string.Format(sqlStr, pgino); ldt = QadOdbcHelper.GetODBCRows(sqlStr); if (ldt.Rows.Count > 0) { ld_ref = ldt.Rows[0]["title"].ToString(); ld_qty_oh = ldt.Rows[0]["value"].ToString(); } DataTable ldt_n = UpdateDataTable(ldt); string json_lot = JsonConvert.SerializeObject(ldt_n); string result = "[{\"flag\":\"" + flag + "\",\"msg\":\"" + msg + "\",\"pn\":\"" + pn + "\",\"descr\":\"" + descr + "\",\"qty\":\"" + qty + "\",\"ld_ref\":\"" + ld_ref + "\",\"ld_qty_oh\":\"" + ld_qty_oh + "\",\"json_lot\":" + json_lot + "}]"; return(result); }