有作用的老代码
老代码,有作用的
using System; using System.Collections.Generic; using System.Text; using Salien.Utility; using Salien.Utility.SUWF; using Salien.Utility.WebControls; using System.Web.UI.WebControls; using System.Data; using System.Web.UI; namespace SLSH34238031111btnSX { public class ClsSX:ISuwfBus { #region ISuwfBus 成员 private SlnSuwfPage page; void ISuwfBus.Initial(SlnSuwfPage page) { this.page = page; try { Button btnSX = (Button)page.FindControl("btnSX"); btnSX.Click+=new EventHandler(btnSX_Click); } catch (Exception ex) { page.ShowMessage(ex.Message); } } //函数atoi,将string型数字变成double型数字 double atoiZhenshu(string shuziStr) { double value = 0; int length = 0; length = shuziStr.Length; char[] chars = shuziStr.ToCharArray();//字符串排成数组 for (int i = 0; i < length; i++) { value = value * 10.0 + chars[i] - '0'; } return value; } public double atoi(string s) //atoi将string s转化为double s { string tmpStr; string strZhenshu = ""; string strXiaoshu = ""; int xiaoshuStrLen = 0; double xiaoShuValue = 1.0; int strLen = 0; char[] chars; int i; tmpStr = s.Trim();//函数的返回值是一个去除开头和结尾空格的字符串 strLen = tmpStr.Length;//字符串长度 chars = tmpStr.ToCharArray();//字符串排成数组 for (i = 0; i < strLen; i++) { if (chars[i] == '.') break;//小数点之前为整数部分,找到整数部分的长度i } if (i == strLen) return atoiZhenshu(tmpStr);//整数位=总位数,则无小数位,返回整数值 else { //public String substring(int beginIndex, int endIndex),该子字符串从指定的 beginIndex 处开始,到指定的 endIndex-1处结束 xiaoshuStrLen = strLen - i - 1;//小数部分的长度,总长度(strLen)-整数长度(i)-小数点长度(1) strZhenshu = tmpStr.Substring(0, i);//string整数值,如如123.456截取从第0位开始的3(i)位数123 if (xiaoshuStrLen > 4) //小数位大于4位 { strXiaoshu = tmpStr.Substring(i + 1, 4);//string小数值,如123.456789截取从第5(i+1)位开始的4位数4567 return atoi(strZhenshu) + 0.0001 * atoi(strXiaoshu);//整数值+小数值 } else //小数位小于4位 { strXiaoshu = tmpStr.Substring(i + 1, xiaoshuStrLen);//string小数值,如123.456截取从第5位(i+1)开始的 xiaoshuStrLen位数456 xiaoShuValue = atoi(strXiaoshu);//double小数值,如123.456中456 for (int j = 0; j < xiaoshuStrLen; j++)//456*0.1*0.1*0.1 { xiaoShuValue = xiaoShuValue * 0.1; } return atoi(strZhenshu) + xiaoShuValue;//整数值+小数值 } } } void btnSX_Click(object sender, EventArgs e) { try { string strBC = ""; string strBCRWID1 = ""; string strBCRWID2 = ""; string strJTLJID = ""; string strJTDDID1 = ""; string strJTDDID2 = ""; string strBCAPID = ""; string strPGRYID = ""; string strBMID = ""; string strBZMS = ""; string strBZQS = ""; //string strHSGS = ""; string strJTID = ""; string strLJID = ""; string strMJID = ""; string strYLID = ""; string strSCSL1 = ""; string strSCSL2 = ""; string strsql1 = ""; string strsql2 = ""; string strsql3 = ""; string strsql4 = ""; string strsql5 = ""; string strsql6 = ""; string strsql71 = ""; string strsql72 = ""; string strsql81 = ""; string strsql82 = ""; DataTable dt1 = null; DataTable dt3 = null; DataTable dt5 = null; strBCAPID = page.GetRowDataByKey(0, "BCAPID");//BCAPID strBC = SlnDataAccess.GetValueBySql(string.Format("select v.BC from SM_SC_ZSBCAP_TB v where v.id='{0}'",strBCAPID)).ToString(); strPGRYID = page.GetValueByName("sys_userid");//登陆人ID为PGRYID //strBMID = SlnDataAccess.GetValueBySql(string.Format("select t.ZYID from sm_jc_gyryzy_tb t where t.ryid='{0}'", strPGRYID)).ToString();//通过派工人员ID找到部门 strBMID = SlnDataAccess.GetValueBySql(string.Format("select zymlid from sm_zdb_yg_tb where id in (select u_no from auth_user_tb where user_id='{0}')", strPGRYID)).ToString();//通过登录人ID找到其部门ID //strsql1 = string.Format("select u.*,t.MJID,t.JTID from SM_SC_ZSJTMJ_TB t, SM_SC_ZSJTLJ_TB u where t.id=u.jtmjid and t.bmid='{0}' and t.pgryid='{1}' and t.jtztbh in (1,2) and t.rwztbh=0 and t.SJKGSJ<=(select v.RQ from SM_SC_ZSBCAP_TB v where v.id='{2}') order by t.jtid", strBMID, strPGRYID, strBCAPID); //派工时间在此班次之前(含此班次)的派工,jtztbh为开工1或完工2状态,rwztbh为有效状态 strsql1 = string.Format("select u.*,t.MJID,t.JTID from SM_SC_ZSJTMJ_TB t, SM_SC_ZSJTLJ_TB u where t.id=u.jtmjid and t.bmid='{0}' and t.pgryid='{1}' and t.jtztbh in (1,2) and u.ljztbh in (1,2) and t.rwztbh=0 order by t.jtid", strBMID, strPGRYID); //所有jtztbh为开工1或完工2状态,rwztbh为有效状态的派工 dt1 = SlnDataAccess.GetDataTable(strsql1); foreach (DataRow row1 in dt1.Rows) { strJTLJID = row1["ID"].ToString();//JTLJID strMJID = row1["MJID"].ToString();//模具ID strJTID = row1["JTID"].ToString();//机台ID strLJID = row1["LJID"].ToString();//零件ID DataTable dt2 = SlnDataAccess.GetDataTable(string.Format("select * from SM_SC_ZSBCRW_TB t where t.BCAPID='{0}' and t.JTID='{1}' and t.LJID='{2}'", strBCAPID, strJTID,strLJID)); if (dt2.Rows.Count == 0) //记录dt2不存在 { strBZMS = SlnDataAccess.GetValueBySql(String.Format("select nvl(sum(t.BZMS),'') from sm_zdb_zsmj_tb t where t.ljid='{0}' and t.jtid='{1}'", strLJID, strJTID)).ToString();//通过零件ID,机台ID找到所对应的标准模数 strBZQS = SlnDataAccess.GetValueBySql(String.Format("select nvl(sum(t.BZQS),'') from sm_zdb_zsmj_tb t where t.ljid='{0}' and t.jtid='{1}'", strLJID, strJTID)).ToString();//通过零件ID,机台ID找到所对应的标准腔数 // strHSGS = SlnDataAccess.GetValueBySql(String.Format("select nvl(sum(t.HSGS),0) from sm_zdb_dwhs_tb t where t.wlid='{0}'", strLJID)).ToString();//通过零件ID所对应的换算公式 strYLID = SlnDataAccess.GetValueBySql(String.Format("select nvl(sum(t.YLID),'') from SM_ZDB_LJYL_TB t where t.ljid='{0}'", strLJID)).ToString();//通过零件ID所对应的原料ID strsql2 = string.Format("INSERT INTO SM_SC_ZSBCRW_TB(IDD,BCAPID,JTLJID,MJID,BZMS,BZQS,HSGS,YLID,RKZT,CKZT,FLZT,JTID,LJID)VALUES(SEQSM_SC_ZSBCRW.NEXTVAL,'{0}','{1}','{2}','{3}','{4}','','{5}',0,0,0,'{6}','{7}')", strBCAPID, strJTLJID, strMJID, strBZMS, strBZQS,strYLID,strJTID,strLJID);//插入增加生产的零件 SlnDataAccess.ExecuteSQL(strsql2); strBCRWID1 = SlnDataAccess.GetValueBySql(string.Format("select IDD from SM_SC_ZSBCRW_TB where BCAPID='{0}' and JTID='{1}' and LJID='{2}'", strBCAPID, strJTID, strLJID)).ToString(); // strsql3 = string.Format("select v.* from SM_SC_ZSJTDD_TB v,SM_SC_ZSJTLJ_TB u,SM_SC_ZSJTMJ_TB t where v.JTLJID=u.id and u.jtmjid=t.id and t.jtid='{0}' and u.ljid='{1}' and v.ddztbh=1 and t.SJKGSJ<=(select w.RQ from SM_SC_ZSBCAP_TB w where w.id='{2}') and v.SCDDID is not null order by v.jhrq", strJTID, strLJID, strBCAPID); strsql3 = string.Format("select v.id,v.scsl from SM_SC_ZSJTDD_TB v,SM_SC_ZSJTLJ_TB u,SM_SC_ZSJTMJ_TB t where v.JTLJID=u.id and u.jtmjid=t.id and t.jtid='{0}' and u.ljid='{1}' and v.ddztbh=1 and v.SCDDID is not null order by v.jhrq", strJTID, strLJID); dt3 = SlnDataAccess.GetDataTable(strsql3); foreach (DataRow row3 in dt3.Rows) { strJTDDID1 = row3["ID"].ToString(); strSCSL1 = row3["SCSL"].ToString(); double douSCSL1 = atoi(strSCSL1); DataTable dt4 = SlnDataAccess.GetDataTable(string.Format("select * from SM_SC_ZSBCRWMX_TB t where t.BCRWID='{0}' and t.JTDDID='{1}'", strBCRWID1, strJTDDID1)); if (dt4.Rows.Count == 0) //记录dt4不存在 { strsql4 = string.Format("INSERT INTO SM_SC_ZSBCRWMX_TB(ID,BCRWID,JTDDID,SCSL,SYSCSL,SYJHSL)VALUES(SEQSM_SC_ZSBCRWMX.NEXTVAL,'{0}','{1}',{2},{3},{4})", strBCRWID1, strJTDDID1, douSCSL1, douSCSL1, douSCSL1);//插入增加生产的订单 SlnDataAccess.ExecuteSQL(strsql4); } else //记录dt4存在 { string strYSCSL11 = SlnDataAccess.GetValueBySql(String.Format("select nvl(sum(t.RKSL),0) from SM_SC_ZSBCRWMX_TB t where t.id in (select w.id from SM_SC_ZSBCRW_TB u, SM_SC_ZSBCAP_TB v, SM_SC_ZSBCRWMX_TB w where u.bcapid = v.id and w.bcrwid = u.idd and v.rq <(select v1.rq from SM_SC_ZSBCRW_TB u1,SM_SC_ZSBCAP_TB v1 where u1.bcapid=v1.id and u1.idd='{0}') and w.JTDDID='{1}')", strBCRWID1, strJTDDID1)).ToString();//今日之前的入库数量之和 string strYJHSL11 = SlnDataAccess.GetValueBySql(String.Format("select nvl(sum(t.RBSL),0) from SM_SC_ZSBCRWMX_TB t where t.id in (select w.id from SM_SC_ZSBCRW_TB u, SM_SC_ZSBCAP_TB v, SM_SC_ZSBCRWMX_TB w where u.bcapid = v.id and w.bcrwid = u.idd and v.rq <(select v1.rq from SM_SC_ZSBCRW_TB u1,SM_SC_ZSBCAP_TB v1 where u1.bcapid=v1.id and u1.idd='{0}') and w.JTDDID='{1}')", strBCRWID1, strJTDDID1)).ToString();//今日之前的日报数量之和 if (strBC == "1")//若是夜班,则找到昨日日班的数据 { double douSYJHSL11 = douSCSL1 - atoi(strYJHSL11);//此班次的剩余计划数量 double douSYSCSL11 = douSCSL1 - atoi(strYSCSL11);//此班次的剩余生产数量 //strsql71 = string.Format("update SM_SC_ZSBCRWMX_TB t set t.syjhsl={0},t.syscsl={1} where t.bcrwid='{2}' and t.jtddid='{3}'", douSYJHSL11, douSYSCSL11,strBCRWID1, strJTDDID1); //SlnDataAccess.ExecuteSQL(strsql71); if (douSYJHSL11 > 0 && douSYSCSL11 > 0)//如果SYJHSL11>0,douSYSCSL11>0,更新SM_SC_ZSBCRWMX_TB的syjhsl=douSYJHSL11,syscsl=douSYSCSL11 { strsql71 = string.Format("update SM_SC_ZSBCRWMX_TB t set t.syjhsl={0},t.syscsl={1} where t.bcrwid='{2}' and t.jtddid='{3}'", douSYJHSL11,douSYSCSL11,strBCRWID1, strJTDDID1); SlnDataAccess.ExecuteSQL(strsql71); } else if (douSYJHSL11 > 0 && douSYSCSL11 <= 0)//如果SYJHSL11>0,douSYSCSL11<=0,更新SM_SC_ZSBCRWMX_TB的syjhsl=douSYJHSL11,syscsl=0 { SlnDataAccess.ExecuteSQL(string.Format("update SM_SC_ZSBCRWMX_TB t set t.syjhsl={0},t.syscsl=0 where t.bcrwid='{1}' and t.jtddid='{2}'", douSYJHSL11,strBCRWID1, strJTDDID1)); } else if (douSYJHSL11 <= 0 && douSYSCSL11 > 0)//如果SYJHSL11<=0,douSYSCSL11>0,更新SM_SC_ZSBCRWMX_TB的syjhsl=0,syscsl=douSYSCSL11 { SlnDataAccess.ExecuteSQL(string.Format("update SM_SC_ZSBCRWMX_TB t set t.syjhsl=0,t.syscsl={0} where t.bcrwid='{1}' and t.jtddid='{2}'", douSYSCSL11, strBCRWID1, strJTDDID1)); } else if (douSYJHSL11 <= 0 && douSYSCSL11 <= 0)//如果SYJHSL11<=0,douSYSCSL11<=0,更新SM_SC_ZSBCRWMX_TB的syjhsl=0,syscsl=0 { SlnDataAccess.ExecuteSQL(string.Format("update SM_SC_ZSBCRWMX_TB t set t.syjhsl=0,t.syscsl=0 where t.bcrwid='{0}' and t.jtddid='{1}'", strBCRWID1, strJTDDID1)); } else { ; } } else //若是日班,则找到今日夜班的数据 { string strYSCSL21 = SlnDataAccess.GetValueBySql(String.Format("select nvl(sum(t.RKSL),0) from SM_SC_ZSBCRWMX_TB t where t.id in (select w.id from SM_SC_ZSBCRW_TB u, SM_SC_ZSBCAP_TB v, SM_SC_ZSBCRWMX_TB w where u.bcapid = v.id and w.bcrwid = u.idd and v.rq= (select v1.rq from SM_SC_ZSBCRW_TB u1,SM_SC_ZSBCAP_TB v1 where u1.bcapid=v1.id and u1.idd='{0}') and v.bc=1 and w.JTDDID='{1}')", strBCRWID1, strJTDDID1)).ToString();//上班次(日班)的入库数量 string strYJHSL21 = SlnDataAccess.GetValueBySql(String.Format("select nvl(sum(t.RBSL),0) from SM_SC_ZSBCRWMX_TB t where t.id in (select w.id from SM_SC_ZSBCRW_TB u, SM_SC_ZSBCAP_TB v, SM_SC_ZSBCRWMX_TB w where u.bcapid = v.id and w.bcrwid = u.idd and v.rq= (select v1.rq from SM_SC_ZSBCRW_TB u1,SM_SC_ZSBCAP_TB v1 where u1.bcapid=v1.id and u1.idd='{0}') and v.bc=1 and w.JTDDID='{1}')", strBCRWID1, strJTDDID1)).ToString();//上班次(日班)的日报数量 double douSYJHSL21 = douSCSL1 - atoi(strYJHSL11) - atoi(strYJHSL21);//此班次的剩余计划数量 double douSYSCSL21 = douSCSL1 - atoi(strYSCSL11) - atoi(strYSCSL21);//此班次的剩余生产数量 //strsql81 = string.Format("update SM_SC_ZSBCRWMX_TB t set t.syjhsl={0},t.syscsl={1} where t.bcrwid='{2}' and t.jtddid='{3}'", douSYJHSL21, douSYSCSL21, strBCRWID1, strJTDDID1); // SlnDataAccess.ExecuteSQL(strsql81); if (douSYJHSL21 > 0 && douSYSCSL21 > 0)//如果SYJHSL21>0,douSYSCSL21>0,更新SM_SC_ZSBCRWMX_TB的syjhsl=douSYJHSL21,syscsl=douSYSCSL21 { strsql81 = string.Format("update SM_SC_ZSBCRWMX_TB t set t.syjhsl={0},t.syscsl={1} where t.bcrwid='{2}' and t.jtddid='{3}'", douSYJHSL21, douSYSCSL21, strBCRWID1, strJTDDID1); SlnDataAccess.ExecuteSQL(strsql81); } else if (douSYJHSL21 > 0 && douSYSCSL21 <= 0)//如果SYJHSL21>0,douSYSCSL21<=0,更新SM_SC_ZSBCRWMX_TB的syjhsl=douSYJHSL21,syscsl=0 { SlnDataAccess.ExecuteSQL(string.Format("update SM_SC_ZSBCRWMX_TB t set t.syjhsl={0},t.syscsl=0 where t.bcrwid='{1}' and t.jtddid='{2}'", douSYJHSL21, strBCRWID1, strJTDDID1)); } else if (douSYJHSL21 <= 0 && douSYSCSL21 > 0)//如果SYJHSL21<=0,douSYSCSL21>0,更新SM_SC_ZSBCRWMX_TB的syjhsl=0,syscsl=douSYSCSL21 { SlnDataAccess.ExecuteSQL(string.Format("update SM_SC_ZSBCRWMX_TB t set t.syjhsl=0,t.syscsl={0} where t.bcrwid='{1}' and t.jtddid='{2}'", douSYSCSL21, strBCRWID1, strJTDDID1)); } else if (douSYJHSL21 <= 0 && douSYSCSL21 <= 0)//如果SYJHSL21<=0,douSYSCSL21<=0,更新SM_SC_ZSBCRWMX_TB的syjhsl=0,syscsl=0 { SlnDataAccess.ExecuteSQL(string.Format("update SM_SC_ZSBCRWMX_TB t set t.syjhsl=0,t.syscsl=0 where t.bcrwid='{0}' and t.jtddid='{1}'", strBCRWID1, strJTDDID1)); } else { ; } } } } } else //记录dt2存在 { strBCRWID2 = SlnDataAccess.GetValueBySql(string.Format("select IDD from SM_SC_ZSBCRW_TB where BCAPID='{0}' and JTID='{1}' and LJID='{2}'", strBCAPID, strJTID, strLJID)).ToString(); //page.ShowMessage(strBCRWID2); //strsql5 = string.Format("select v.* from SM_SC_ZSJTDD_TB v,SM_SC_ZSJTLJ_TB u,SM_SC_ZSJTMJ_TB t where v.JTLJID=u.id and u.jtmjid=t.id and t.jtid='{0}' and u.ljid='{1}' and v.ddztbh=1 and t.SJKGSJ<=(select w.RQ from SM_SC_ZSBCAP_TB w where w.id='{2}') and v.SCDDID is not null order by v.jhrq", strJTID, strLJID, strBCAPID); strsql5 = string.Format("select v.* from SM_SC_ZSJTDD_TB v,SM_SC_ZSJTLJ_TB u,SM_SC_ZSJTMJ_TB t where v.JTLJID=u.id and u.jtmjid=t.id and t.jtid='{0}' and u.ljid='{1}' and v.ddztbh=1 and v.SCDDID is not null order by v.jhrq", strJTID, strLJID); dt5 = SlnDataAccess.GetDataTable(strsql5); foreach (DataRow row5 in dt5.Rows) { strJTDDID2 = row5["ID"].ToString(); strSCSL2 = row5["SCSL"].ToString(); double douSCSL2 = atoi(strSCSL2); DataTable dt6 = SlnDataAccess.GetDataTable(string.Format("select * from SM_SC_ZSBCRWMX_TB t where t.BCRWID='{0}' and t.JTDDID='{1}'", strBCRWID2, strJTDDID2)); if (dt6.Rows.Count == 0) //记录dt4不存在 { strsql6 = string.Format("INSERT INTO SM_SC_ZSBCRWMX_TB(ID,BCRWID,JTDDID,SCSL,SYSCSL,SYJHSL)VALUES(SEQSM_SC_ZSBCRWMX.NEXTVAL,'{0}','{1}',{2},{3},{4})", strBCRWID2, strJTDDID2, douSCSL2, douSCSL2, douSCSL2);//插入增加生产的订单 SlnDataAccess.ExecuteSQL(strsql6); } else //记录dt4存在 { string strYSCSL12 = SlnDataAccess.GetValueBySql(String.Format("select nvl(sum(t.RKSL),0) from SM_SC_ZSBCRWMX_TB t where t.id in (select w.id from SM_SC_ZSBCRW_TB u, SM_SC_ZSBCAP_TB v, SM_SC_ZSBCRWMX_TB w where u.bcapid = v.id and w.bcrwid = u.idd and v.rq <(select v1.rq from SM_SC_ZSBCRW_TB u1,SM_SC_ZSBCAP_TB v1 where u1.bcapid=v1.id and u1.idd='{0}') and w.JTDDID='{1}')", strBCRWID2, strJTDDID2)).ToString();//今日之前的入库数量之和 string strYJHSL12 = SlnDataAccess.GetValueBySql(String.Format("select nvl(sum(t.RBSL),0) from SM_SC_ZSBCRWMX_TB t where t.id in (select w.id from SM_SC_ZSBCRW_TB u, SM_SC_ZSBCAP_TB v, SM_SC_ZSBCRWMX_TB w where u.bcapid = v.id and w.bcrwid = u.idd and v.rq <(select v1.rq from SM_SC_ZSBCRW_TB u1,SM_SC_ZSBCAP_TB v1 where u1.bcapid=v1.id and u1.idd='{0}') and w.JTDDID='{1}')", strBCRWID2, strJTDDID2)).ToString();//今日之前的日报数量之和 if (strBC == "1")//若是夜班,则找到昨日日班的数据 { double douSYJHSL12 = douSCSL2 - atoi(strYJHSL12);//此班次的剩余计划数量 double douSYSCSL12 = douSCSL2 - atoi(strYSCSL12);//此班次的剩余生产数量 //strsql72 = string.Format("update SM_SC_ZSBCRWMX_TB t set t.syjhsl={0},t.syscsl={1} where t.bcrwid='{2}' and t.jtddid='{3}'", douSYJHSL12, douSYSCSL12, strBCRWID2, strJTDDID2); //SlnDataAccess.ExecuteSQL(strsql72); if (douSYJHSL12 > 0 && douSYSCSL12 > 0)//如果SYJHSL12>0,douSYSCSL12>0,更新SM_SC_ZSBCRWMX_TB的syjhsl=douSYJHSL12,syscsl=douSYSCSL12 { strsql72 = string.Format("update SM_SC_ZSBCRWMX_TB t set t.syjhsl={0},t.syscsl={1} where t.bcrwid='{2}' and t.jtddid='{3}'", douSYJHSL12, douSYSCSL12, strBCRWID2, strJTDDID2); SlnDataAccess.ExecuteSQL(strsql72); } else if (douSYJHSL12 > 0 && douSYSCSL12 <= 0)//如果SYJHSL12>0,douSYSCSL12<=0,更新SM_SC_ZSBCRWMX_TB的syjhsl=douSYJHSL12,syscsl=0 { SlnDataAccess.ExecuteSQL(string.Format("update SM_SC_ZSBCRWMX_TB t set t.syjhsl={0},t.syscsl=0 where t.bcrwid='{1}' and t.jtddid='{2}'", douSYJHSL12, strBCRWID2, strJTDDID2)); } else if (douSYJHSL12 <= 0 && douSYSCSL12 > 0)//如果SYJHSL12<=0,douSYSCSL12>0,更新SM_SC_ZSBCRWMX_TB的syjhsl=0,syscsl=douSYSCSL12 { SlnDataAccess.ExecuteSQL(string.Format("update SM_SC_ZSBCRWMX_TB t set t.syjhsl=0,t.syscsl={0} where t.bcrwid='{1}' and t.jtddid='{2}'", douSYSCSL12, strBCRWID2, strJTDDID2)); } else if (douSYJHSL12 <= 0 && douSYSCSL12 <= 0)//如果SYJHSL12<=0,douSYSCSL12<=0,更新SM_SC_ZSBCRWMX_TB的syjhsl=0,syscsl=0 { SlnDataAccess.ExecuteSQL(string.Format("update SM_SC_ZSBCRWMX_TB t set t.syjhsl=0,t.syscsl=0 where t.bcrwid='{0}' and t.jtddid='{1}'", strBCRWID2, strJTDDID2)); } else { ; } } else //若是日班,则找到今日夜班的数据 { string strYSCSL22 = SlnDataAccess.GetValueBySql(String.Format("select nvl(sum(t.RKSL),0) from SM_SC_ZSBCRWMX_TB t where t.id in (select w.id from SM_SC_ZSBCRW_TB u, SM_SC_ZSBCAP_TB v, SM_SC_ZSBCRWMX_TB w where u.bcapid = v.id and w.bcrwid = u.idd and v.rq= (select v1.rq from SM_SC_ZSBCRW_TB u1,SM_SC_ZSBCAP_TB v1 where u1.bcapid=v1.id and u1.idd='{0}') and v.bc=1 and w.JTDDID='{1}')", strBCRWID2, strJTDDID2)).ToString();//上班次(日班)的入库数量 string strYJHSL22 = SlnDataAccess.GetValueBySql(String.Format("select nvl(sum(t.RBSL),0) from SM_SC_ZSBCRWMX_TB t where t.id in (select w.id from SM_SC_ZSBCRW_TB u, SM_SC_ZSBCAP_TB v, SM_SC_ZSBCRWMX_TB w where u.bcapid = v.id and w.bcrwid = u.idd and v.rq= (select v1.rq from SM_SC_ZSBCRW_TB u1,SM_SC_ZSBCAP_TB v1 where u1.bcapid=v1.id and u1.idd='{0}') and v.bc=1 and w.JTDDID='{1}')", strBCRWID2, strJTDDID2)).ToString();//上班次(日班)的日报数量 double douSYJHSL22 = douSCSL2 - atoi(strYJHSL12) - atoi(strYJHSL22);//此班次的剩余计划数量 double douSYSCSL22 = douSCSL2 - atoi(strYSCSL12) - atoi(strYSCSL22);//此班次的剩余生产数量 //strsql82 = string.Format("update SM_SC_ZSBCRWMX_TB t set t.syjhsl={0},t.syscsl={1} where t.bcrwid='{2}' and t.jtddid='{3}'", douSYJHSL22, douSYSCSL22, strBCRWID2, strJTDDID2); //SlnDataAccess.ExecuteSQL(strsql82); if (douSYJHSL22 > 0 && douSYSCSL22 > 0)//如果SYJHSL22>0,douSYSCSL22>0,更新SM_SC_ZSBCRWMX_TB的syjhsl=douSYJHSL22,syscsl=douSYSCSL22 { strsql82 = string.Format("update SM_SC_ZSBCRWMX_TB t set t.syjhsl={0},t.syscsl={1} where t.bcrwid='{2}' and t.jtddid='{3}'", douSYJHSL22, douSYSCSL22, strBCRWID2, strJTDDID2); SlnDataAccess.ExecuteSQL(strsql82); } else if (douSYJHSL22 > 0 && douSYSCSL22 <= 0)//如果SYJHSL22>0,douSYSCSL22<=0,更新SM_SC_ZSBCRWMX_TB的syjhsl=douSYJHSL22,syscsl=0 { SlnDataAccess.ExecuteSQL(string.Format("update SM_SC_ZSBCRWMX_TB t set t.syjhsl={0},t.syscsl=0 where t.bcrwid='{1}' and t.jtddid='{2}'", douSYJHSL22, strBCRWID2, strJTDDID2)); } else if (douSYJHSL22 <= 0 && douSYSCSL22 > 0)//如果SYJHSL22<=0,douSYSCSL22>0,更新SM_SC_ZSBCRWMX_TB的syjhsl=0,syscsl=douSYSCSL22 { SlnDataAccess.ExecuteSQL(string.Format("update SM_SC_ZSBCRWMX_TB t set t.syjhsl=0,t.syscsl={0} where t.bcrwid='{1}' and t.jtddid='{2}'", douSYSCSL22, strBCRWID2, strJTDDID2)); } else if (douSYJHSL22 <= 0 && douSYSCSL22 <= 0)//如果SYJHSL22<=0,douSYSCSL22<=0,更新SM_SC_ZSBCRWMX_TB的syjhsl=0,syscsl=0 { SlnDataAccess.ExecuteSQL(string.Format("update SM_SC_ZSBCRWMX_TB t set t.syjhsl=0,t.syscsl=0 where t.bcrwid='{0}' and t.jtddid='{1}'", strBCRWID2, strJTDDID2)); } else { ; } } } } } } page.btnQuery_Click(null, null); } catch (Exception ex) { page.ShowMessage(ex.Message); } } #endregion } }
浙公网安备 33010602011771号