public int AddDelivery(int userid, string wordDate, string barcode, string tisaneNum, string imgname, string userName, string kd_type, string kd_num, string demo) { // string sql = "insert into Delivery(employeeId,SendTime,barcode,DecoctingNum,imgname,Sendstate,Sendpersonnel,kd_type,kd_num,demo) values('" + // userid + "','" + wordDate + "','" + barcode + "','" + tisaneNum + "','" + imgname + "','1" + "','" // + userName + "','" + kd_type + "','" + kd_num + "','" + demo + "')"; #region 添加发货时判断包装是否完成,未完成,设置包装结束时间:包装开始时间+包装代数*预设时间 db.sp_Execute_no_return("sp_auto_packing", Convert.ToInt32(tisaneNum)); #endregion string sql = "update Delivery set employeeId='" + userid + "',SendTime='" + wordDate + "',barcode='" + barcode + "',imgname='" + imgname + "',Sendstate='1',Sendpersonnel='" + userName + "',kd_type='" + kd_type + "'" + ",kd_num='" + kd_num + "'" + ",demo='" + demo + "'" + " where DecoctingNum='" + tisaneNum + "'"; string sql2 = "update prescription set doperson ='" + userName + "',curstate = '已发货' where id = '" + tisaneNum + "'"; // Console.WriteLine("sql:" + sql); // Console.ReadLine(); // Console.WriteLine("sql:" + sql2); db.cmd_Execute(sql2); //写log文件 db.write_log_txt("sql:" + sql + "-------" + "sql:" + sql2); return(db.cmd_Execute(sql)); }
public int addPacking(int userid, string wordDate, string barcode, string tisaneNum, string imgname, string userName) { #region 当没有收到煎药完成指令和开始排液指令,触发判断煎药是否完成未完成将煎药时间设置为开始煎药时间+25MIN+煎药方案时间 try { //包装流程修改,若煎药流程结束,扫码开始包装,包装代数为实际代数+多包代数。 //多包代数 string str11 = "select top 1 package_machine_nums from dbo.tb_sys_add_setting"; SqlDataReader sr11 = db.get_Reader(str11); int more_num = 0; if (sr11.Read()) { more_num = Convert.ToInt32(sr11["package_machine_nums"].ToString()); string sql12 = "update prescription set packstatus=packstatus+more_num where id = '" + tisaneNum.ToString().Trim() + "'"; db.cmd_Execute(sql12); } db.sp_Execute_no_return("sp_auto_tisane", Convert.ToInt32(tisaneNum)); } catch { } #endregion string sql = "insert into packing(employeeId,Starttime,barcode,DecoctingNum,imgname,Fpactate,Pacpersonnel) values('" + userid + "','" + wordDate + "','" + barcode + "','" + tisaneNum + "','" + imgname + "','0" + "','" + userName + "')"; string sql2 = "update prescription set doperson ='" + userName + "',curstate = '开始包装' where id = '" + tisaneNum + "'"; db.cmd_Execute(sql2); int count = db.cmd_Execute(sql); if (count > 0) { BaseInfo.Insert_PackCmd(Convert.ToDateTime(wordDate), db, tisaneNum);//开始包装 string sqlStr = "update machine set status='空闲',pid='' where id=(select machineid from tisaneunit where pid='" + tisaneNum + "')"; db.cmd_Execute(sqlStr); sqlStr = "update machine set status='忙碌',pid='" + tisaneNum + "' where id=(SELECT c.id FROM machine AS c INNER JOIN (SELECT a.id, a.roomnum, a.mark, a.unitnum FROM machine AS a INNER JOIN (SELECT machineid FROM tisaneunit WHERE (pid = '" + tisaneNum + "')) AS b ON a.id = b.machineid) AS d ON d.roomnum = c.roomnum AND d.unitnum = c.unitnum AND c.mark = 1)"; db.cmd_Execute(sqlStr); } return(count); }
public int AddPacking(int DecoctingNum, string PackPer) { int end = 0; /// <summary> /// 添加包装信息 /// </summary> /// <param name="einfo"></param> /// <returns></returns> /// #region 当没有收到煎药完成指令和开始排液指令,触发判断煎药是否完成未完成将煎药时间设置为开始煎药时间+25MIN+煎药方案时间 try { //包装流程修改,若煎药流程结束,扫码开始包装,包装代数为实际代数+多包代数。 //多包代数 string str11 = "select top 1 package_machine_nums from dbo.tb_sys_add_setting"; SqlDataReader sr11 = db.get_Reader(str11); int more_num = 0; if (sr11.Read()) { more_num = Convert.ToInt32(sr11["package_machine_nums"].ToString()); // string sql12 = "update prescription set packagenum =packagenum+" + more_num.ToString() + " where id = '" + DecoctingNum.ToString().Trim() + "'";//+" and "+"'"++"'"; // db.cmd_Execute(sql12); string sql13 = "update tisaneinfo set tisanestatus ='1' where pid ='" + DecoctingNum.ToString().Trim() + "'"; db.cmd_Execute(sql13); } sr11.Close(); db.sp_Execute_no_return("sp_auto_tisane", DecoctingNum); } catch { end = 0; } #endregion String sql = ""; string per = PackPer.Substring(6); string employeeid = ""; string str7 = "select id from employee where EmNumAName ='" + PackPer + "'"; SqlDataReader sr7 = db.get_Reader(str7); if (sr7.Read()) { employeeid = sr7["id"].ToString(); } string str = "select pid from tisaneinfo where tisanestatus = 1 and pid = '" + DecoctingNum + "'"; //and pid not in (select pid from InvalidPrescription) SqlDataReader sr = db.get_Reader(str); System.DateTime now = new System.DateTime(); now = System.DateTime.Now; #region if 1 if (sr.Read()) { string result = sr["pid"].ToString(); int a = Convert.ToInt32(result); string str1 = "select * from Packing where DecoctingNum = '" + a + "'"; SqlDataReader sr1 = db.get_Reader(str1); #region 是否包装判断 if (sr1.Read()) { string start = "select Starttime from Packing where DecoctingNum = '" + a + "'"; SqlDataReader starttime = db.get_Reader(start); string starttime2 = ""; if (starttime.Read()) { string tate = "select Fpactate from Packing where DecoctingNum = '" + a + "'"; SqlDataReader tate1 = db.get_Reader(tate); if (tate1.Read()) { if (tate1["Fpactate"].ToString() == "0") { starttime2 = starttime["Starttime"].ToString(); //获取包装时间 DateTime starttime1 = Convert.ToDateTime(starttime2); //开始时间 string now1 = now.ToString("yyyy-MM-dd HH:mm:ss"); DateTime d3 = Convert.ToDateTime(now1); //把当前时间转变为datetime TimeSpan d4 = d3.Subtract(starttime1); //开始时间-当前时间 int fpack = Convert.ToInt32(d4.Days.ToString()) * 24 * 60 + Convert.ToInt32(d4.Hours.ToString()) * 60 + Convert.ToInt32(d4.Minutes.ToString()); //差值转换为分钟数 string packtime = fpack.ToString(); //sql = "INSERT INTO [Packing](DecoctingNum,packtime,Fpactate) VALUES('" + a + "','" + fpack + "','" + 2 + "')"; sql = "Update Packing set PacTime='" + now + "', Fpactate ='1' where DecoctingNum = '" + a + "'"; if (db.cmd_Execute(sql) == 1) { string sql1 = "update prescription set curstate = '包装完成' where id = '" + a + "'"; if (db.cmd_Execute(sql1) == 1) { string sql2 = "INSERT INTO [Delivery](DecoctingNum,Sendstate) VALUES('" + a + "','0')"; if (db.cmd_Execute(sql2) == 1) { string str5 = "select machineid from tisaneunit where pid = '" + DecoctingNum + "'"; SqlDataReader sr01 = db.get_Reader(str5); if (sr01.Read()) { string machineid = sr01["machineid"].ToString(); //更改包装机状态 string sq6 = "select unitnum from machine where id = '" + machineid + "'"; SqlDataReader sr6 = db.get_Reader(sq6); if (sr6.Read()) { string unitnum = sr6["unitnum"].ToString(); string sq7 = "update machine set status ='空闲' where unitnum = '" + unitnum + "' and mark =1"; db.cmd_Execute(sq7); } } } } } } else { sql = ""; } } } } #endregion #region 未开始包装判断 else { string sql2 = "INSERT INTO [Packing](DecoctingNum,Starttime,Fpactate,Pacpersonnel,employeeid) VALUES('" + a + "','" + now + "','" + 0 + "','" + per + "','" + employeeid + "')"; //开始包装 BaseInfo.Insert_PackCmd(now, db, DecoctingNum.ToString()); //SqlDataReader tate13 = db.get_Reader(sql2); if (db.cmd_Execute(sql2) == 1) { sql = "update prescription set doperson ='" + per + "',curstate = '开始包装' where id = '" + a + "'"; db.cmd_Execute(sql); // sql = "update prescription set doperson ='" + per + "',curstate = '开始包装' where id = '" + a + "'"; //db.cmd_Execute(sql2); //把机组表里的包装状态设为1 string now1 = now.ToString("yyyy-MM-dd HH:mm:ss"); DateTime d3 = Convert.ToDateTime(now1);//把当前时间转变为datetime sql = "update tisaneunit set packstatus = 1,endDate ='" + d3 + "' where pid ='" + a + "'"; db.cmd_Execute(sql); //更改煎药机状态为空闲 //string changetisanestatu = "update machine set status ='空闲' where id = (select machineid from tisaneunit where pid = '"+a+"')"; // db.cmd_Execute(changetisanestatu); //更改包装机状态为忙碌 // string changepackstatu = "update machine set status ='忙碌' where id = (select machineid from tisaneunit where pid = '" + a + "')"; // db.cmd_Execute(changepackstatu); string machineid = ""; string unitnum = ""; string str5 = "select machineid from tisaneunit where pid = '" + DecoctingNum + "'"; SqlDataReader sr5 = db.get_Reader(str5); if (sr5.Read()) { machineid = sr5["machineid"].ToString(); //更改包装机状态 string sq6 = "select unitnum from machine where id = '" + machineid + "'"; SqlDataReader sr6 = db.get_Reader(sq6); if (sr6.Read()) { unitnum = sr6["unitnum"].ToString(); string sq7 = "update machine set status ='忙碌' where unitnum = '" + unitnum + "'and mark =1"; db.cmd_Execute(sq7); } } string sql9 = "update machine set status ='空闲' where id = '" + machineid + "'"; db.cmd_Execute(sql9); } } #endregion } #endregion else { sql = ""; } if (sql == "") { end = 0; } else { // end = db.cmd_Execute(sql); end = 1; } return(end); }