市长热线演示版

workordernew.aspx.cs 31KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using HySoft.Common;
  8. using HySoft.Workflow.WFEngine;
  9. using WOSBusineSupporter;
  10. using System.Data;
  11. namespace HySoft.BaseCallCenter.Web.workordermanage.workorder
  12. {
  13. public partial class workordernew : System.Web.UI.Page
  14. {
  15. string phone = "";
  16. string callid = "";
  17. string zxflowid = "7";
  18. string bxflowid = "6";
  19. string tsflowid = "5";
  20. string assOpt = "";
  21. protected void Page_Load(object sender, EventArgs e)
  22. {
  23. #region 生成流程操作
  24. InitEngine();
  25. #endregion
  26. if (!IsPostBack)
  27. {
  28. #region 获取用户信息
  29. try
  30. {
  31. LoginUser p_LoginUser = new LoginUser(this.Context);
  32. hfUserId.Value = p_LoginUser.UserID.ToString();
  33. }
  34. catch { }
  35. #endregion
  36. }
  37. }
  38. #region 初始化工作流引擎
  39. private void InitEngine()
  40. {
  41. wosBusineSupporter = new WOSBusineSupporter.WOSBusineSupporter();
  42. wosBusineSupporter.ConnectionString = connStr;
  43. /**/
  44. //SQL数据库存储方式
  45. MSSQLDBWorkflowInstanceFactory instanceFactory = new MSSQLDBWorkflowInstanceFactory();
  46. instanceFactory.ConnectionString = connStr;
  47. MSSQLDBPersistentServer persistenServer = new MSSQLDBPersistentServer();
  48. persistenServer.ConnectionString = connStr;
  49. engine = new SimpleWFEngine(wosBusineSupporter, persistenServer, instanceFactory);
  50. //咨询流程
  51. MSSQLDBWorkflowTypeInfoSupporter sup = new MSSQLDBWorkflowTypeInfoSupporter();
  52. sup.ConnectionString = connStr;
  53. runOprs = null;
  54. sup.GetWorkflowTypeInfo(tsflowid,
  55. out nodeID, out nodeType, out nodeName, out formInfo, out enablcRepeal, out enablcRepealLock, out runOprs, out rollBackOprs, out assignParticipatorArray);
  56. #region 投诉操作
  57. if (runOprs != null)
  58. {
  59. int idcount = 0;
  60. foreach (BusineOpr runopr in runOprs)
  61. {
  62. //zxoptid = runopr.ID;
  63. LinkButton runSavebtn = new LinkButton();
  64. runSavebtn.ID = "runSavebtnts" + idcount.ToString();
  65. runSavebtn.Attributes.Add("class", "btnSubmit");
  66. runSavebtn.OnClientClick = "return validate('" + runopr.ID.Trim() + "')";
  67. runSavebtn.Text = runopr.Name.Trim();
  68. runSavebtn.CommandArgument = runopr.ID + "_" + nodeID;
  69. runSavebtn.Height = 23;
  70. runSavebtn.Click += new EventHandler(btnSubmit_Click);
  71. divOpt0.Controls.Add(runSavebtn);
  72. //添加空格间距
  73. System.Web.UI.HtmlControls.HtmlGenericControl spannull = new System.Web.UI.HtmlControls.HtmlGenericControl("span");
  74. spannull.ID = "btnnullts" + idcount.ToString();
  75. spannull.InnerText = " ";
  76. divOpt0.Controls.Add(spannull);
  77. idcount++;
  78. }
  79. }
  80. #endregion
  81. }
  82. #endregion
  83. #region 来电归属地查询
  84. public string GetPhoneLocation(string phoneNumber, bool isPhone)
  85. {
  86. string location = "未知";
  87. try
  88. {
  89. //如果是手机号码
  90. if (isPhone)
  91. {
  92. BLL.T_Sys_MobileData mobile_Bll = new BLL.T_Sys_MobileData();
  93. Model.T_Sys_MobileData mobileModel = mobile_Bll.GetModel(phoneNumber.Substring(0, 7));
  94. return mobileModel != null ? (mobileModel.F_CityDes + mobileModel.F_CardDes) : location;
  95. }
  96. else//如果是电话号码
  97. {
  98. BLL.T_Sys_TelTitleData numbBll = new BLL.T_Sys_TelTitleData();
  99. List<Model.T_Sys_TelTitleData> mobileModel = numbBll.GetModelList(" 1=1 and F_KeyPhoneNum='" + phoneNumber.Substring(0, 4) + "'");
  100. if (mobileModel == null || mobileModel.Count <= 0)
  101. mobileModel = numbBll.GetModelList(" 1=1 and F_KeyPhoneNum='" + phoneNumber.Substring(0, 3) + "'");
  102. return mobileModel.Count > 0 ? mobileModel[0].F_TitleName : location;
  103. }
  104. }
  105. catch (System.Exception ex)
  106. {
  107. return location;
  108. }
  109. }
  110. #endregion
  111. #region 获取通话记录信息
  112. private string GetTelRecord(string callid)
  113. {
  114. string res = "0";
  115. try
  116. {
  117. Model.T_Call_CallRecords model = new BLL.T_Call_CallRecords().GetModelByCallId(callid);
  118. if (model != null)
  119. {
  120. res = model.CallRecordsId.ToString();
  121. hfBusinessType.Value = model.BusinessType.ToString().Trim();
  122. }
  123. }
  124. catch
  125. {
  126. }
  127. return res;
  128. }
  129. #endregion
  130. SimpleWFEngine engine;
  131. WOSBusineSupporter.WOSBusineSupporter wosBusineSupporter;
  132. string connStr = DBUtility.DbHelperSQL.connectionString;
  133. string instanceID = "0";
  134. string nodeID = "0";
  135. BusineTaskType nodeType;
  136. string nodeName = "";
  137. string formInfo = "";
  138. bool enablcRepeal;
  139. bool enablcRepealLock;
  140. BusineOpr[] runOprs = null;
  141. BusineOpr[] rollBackOprs;
  142. AssignParticipator[] assignParticipatorArray;
  143. static string typeid = "0";
  144. static string formid = "0";
  145. static string flowid = "0";
  146. protected void btnSubmit_Click(object sender, EventArgs e)
  147. {
  148. #region 保存客户信息
  149. try
  150. {
  151. if (hiddCustomerId.Value == "" || hiddCustomerId.Value == "0")
  152. {
  153. if (txtCustomerName.Text.Trim() != "")
  154. {
  155. //添加客户
  156. int id = new BLL.T_Cus_CustomerBase().Add(GetCustomerModel());
  157. if (id > 0)
  158. {
  159. hiddCustomerId.Value = id.ToString();
  160. }
  161. }
  162. }
  163. else
  164. {
  165. //修改客户
  166. new BLL.T_Cus_CustomerBase().Update(GetCustomerModel());
  167. }
  168. }
  169. catch (Exception ex)
  170. {
  171. }
  172. #endregion
  173. #region 保存工单
  174. string errorInfo = "";
  175. try
  176. {
  177. flowid = tsflowid;
  178. typeid = "3";
  179. WorkflowOprErr errbl = engine.CreateWorkflowInstance(flowid, hfUserId.Value.Trim(), out instanceID, out errorInfo);
  180. if (errbl == WorkflowOprErr.OK)
  181. {
  182. //提交保存工单
  183. int f_instanceid = Convert.ToInt32(instanceID);
  184. int workorderid = 0;
  185. bool bl = SubmitOSubmit(f_instanceid, flowid, hfTab.Value.Trim(), out workorderid);
  186. if (bl)
  187. {
  188. //InsertOptLogs("", "添加工单成功!工单编号为:" + model_orderbase.F_CODE, 0);
  189. LinkButton btn = (LinkButton)sender;
  190. string arrid = btn.CommandArgument;
  191. string optid = "6";
  192. if (arrid != "")
  193. {
  194. nodeID = arrid.Split('_')[1];
  195. optid = arrid.Split('_')[0];
  196. }
  197. //判断操作
  198. if (optid == "18" || optid == "19")
  199. {
  200. string optnodeid = "";
  201. string optnodename = "";
  202. if (optid == "18")
  203. {
  204. optnodeid = "6";
  205. optnodename = "待接单";
  206. SaveConsInfo(workorderid.ToString(), hiddJDUser.Value);
  207. }
  208. if (optid == "19")
  209. {
  210. optnodeid = "4";
  211. optnodename = "待指派";
  212. }
  213. WorkflowOprErr bRet = engine.RunOpr(instanceID, hfUserId.Value.Trim(), nodeID, optid, GetAssignParticipatorList(hiddJDUser.Value, instanceID), "工单操作:" + btn.Text, out errorInfo);
  214. //WorkflowOprErr bRet = engine.RunOpr(instanceID, hfUserId.Value.Trim(), nodeID, optid, GetAssignParticipatorList(hiddJDUser.Value, optnodeid, optnodename), "工单操作:" + btn.Text, out errorInfo);
  215. }
  216. else
  217. {
  218. WorkflowOprErr bRet = engine.RunOpr(instanceID, hfUserId.Value.Trim(), nodeID, optid, null, "工单操作:" + btn.Text, out errorInfo);
  219. if (bRet.ToString() == "OK" && btn.Text == "结单")
  220. {
  221. SaveHistoryInfo();
  222. }
  223. }
  224. MessageBoxToWindow("保存提示", "保存成功!", "success");
  225. //ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>TabCloseById('callin_" + callid + phone + "');</script>");
  226. }
  227. else
  228. {
  229. //InsertOptLogs("", "添加工单失败!", 1);
  230. MessageBoxToWindow("保存提示", "新增失败!", "error");
  231. }
  232. }
  233. else
  234. {
  235. MessageBoxToWindow("保存提示", "创建工作流实例失败" + errbl.ToString(), "error");
  236. }
  237. }
  238. catch (Exception ex)
  239. {
  240. //保存工单失败
  241. MessageBoxToWindow("提示", "异常提示!" + ex.Message, "catch");
  242. }
  243. #endregion
  244. }
  245. private AssignParticipator[] GetAssignParticipatorList(string userid, string instanceID)
  246. {
  247. Model.T_Wo_WorkOrderTask obj = new Model.T_Wo_WorkOrderTask();
  248. DataTable dt = new DataTable();
  249. try
  250. {
  251. dt = new BLL.T_Wo_WorkOrderTask().GetList("F_INSTANCEID=" + instanceID + "").Tables[0];
  252. if (dt.Rows.Count > 0)
  253. {
  254. if (dt.Rows[0]["F_AssignParticipator"].ToString() != "null")
  255. {
  256. assOpt = dt.Rows[0]["F_AssignParticipator"].ToString();
  257. }
  258. }
  259. }
  260. catch { }
  261. if (assOpt != "")
  262. {
  263. AssignParticipator[] asslist = new Web.tools.ParseWorkFlowTask().ParseAssignParticipatorOpr(assOpt);
  264. foreach (AssignParticipator ass in asslist)
  265. {
  266. ParticipatorInfo partinfo = new ParticipatorInfo();
  267. List<Model.T_Sys_UserAccount> list = new List<Model.T_Sys_UserAccount>();
  268. list = (new BLL.T_Sys_UserAccount()).GetModelList(" F_UserId=" + userid.Trim() + "");
  269. UserInfo[] userlist = new UserInfo[list.Count];
  270. for (int i = 0; i < userlist.Length; i++)
  271. {
  272. UserInfo user = new UserInfo();
  273. user.ID = list[i].F_UserId.ToString();
  274. user.Name = list[i].F_UserName;
  275. userlist[i] = user;
  276. }
  277. partinfo.UserList = userlist;
  278. ass.ParticipatorInfo = new AssembleWorkFlowTask().AssembleParticipator(partinfo).InnerXml;
  279. }
  280. return asslist;
  281. }
  282. else
  283. {
  284. return null;
  285. }
  286. }
  287. /// <summary>
  288. /// 添加施工人员
  289. /// </summary>
  290. /// <returns></returns>
  291. private string SaveConsInfo(string workorderid, string userid)
  292. {
  293. string res = "error";
  294. try
  295. {
  296. Model.T_Wo_WorkOrderConstructor modelConstructor = new Model.T_Wo_WorkOrderConstructor();
  297. BLL.T_Wo_WorkOrderConstructor bll_Constructoradd = new BLL.T_Wo_WorkOrderConstructor();
  298. modelConstructor.F_WORKORDERID = Convert.ToInt32(workorderid);//工单ID
  299. modelConstructor.F_USERID = Convert.ToInt32(userid);
  300. modelConstructor.F_ISMAIN = 1;
  301. int i = bll_Constructoradd.Add(modelConstructor);
  302. if (i > 0)
  303. {
  304. res = "success";
  305. }
  306. }
  307. catch (Exception ex)
  308. {
  309. }
  310. return res;
  311. }
  312. /// <summary>
  313. /// 指派人员
  314. /// </summary>
  315. /// <param name="userid"></param>
  316. /// <param name="optnodeid"></param>
  317. /// <param name="optnodename"></param>
  318. /// <returns></returns>
  319. private AssignParticipator[] GetAssignParticipatorList(string userid, string optnodeid, string optnodename)
  320. {
  321. AssignParticipator[] arr = new AssignParticipator[1];
  322. arr[0] = new AssignParticipator();
  323. arr[0].NodeID = optnodeid;
  324. arr[0].NodeName = optnodename;
  325. ParticipatorInfo partinfo = new ParticipatorInfo();
  326. List<Model.T_Sys_UserAccount> list = new List<Model.T_Sys_UserAccount>();
  327. list = (new BLL.T_Sys_UserAccount()).GetModelList(" F_UserId=" + userid.Trim() + "");
  328. UserInfo[] userlist = new UserInfo[list.Count];
  329. for (int i = 0; i < userlist.Length; i++)
  330. {
  331. UserInfo user = new UserInfo();
  332. user.ID = list[i].F_UserId.ToString();
  333. user.Name = list[i].F_UserName;
  334. userlist[i] = user;
  335. }
  336. partinfo.UserList = userlist;
  337. arr[0].ParticipatorInfo = new AssembleWorkFlowTask().AssembleParticipator(partinfo).InnerXml;
  338. return arr;
  339. }
  340. public bool SubmitOSubmit(int instanceID, string _flowid, string tab, out int workorderid)
  341. {
  342. bool bl = false;
  343. workorderid = 0;
  344. try
  345. {
  346. Model.T_Wo_WorkOrderBase model = new Model.T_Wo_WorkOrderBase();
  347. #region 工单信息
  348. model.F_WORKORDERTYPEID = Convert.ToInt32(typeid);//类型ID
  349. model.F_WORKORDERSTATEID = Convert.ToInt32(nodeID);//状态ID
  350. model.F_CODE = DateTime.Now.ToString("yyyyMMddHHmmssms");//工单编号
  351. model.F_WORKORDERNAME = txtCustomerName.Text.Trim() + "报修工单";//工单名称
  352. model.F_NUMBER = model.F_CODE;
  353. model.F_CUSTOMERNAME = txtCustomerName.Text.Trim();//客户姓名
  354. model.F_CUSTOMERTELEPHONE = this.txtTsPhone.Text.Trim();//客户电话
  355. model.F_LINKMAN = this.txtTsName.Text.Trim();//联系人姓名
  356. model.F_LINKMANTELEPHONE = this.txtTsPhone.Text.Trim();//联系人电话
  357. model.F_ADSLACCOUNT = hfCallId.Value.Trim();
  358. model.F_BANDWIDTH = "";
  359. //model.F_STANDARDADDRESS = F_STANDARDADDRESS;
  360. //model.F_INSTALLADDRESS = F_INSTALLADDRESS;
  361. model.F_KSHADDRESSCODE = "";
  362. model.F_PROVINCE = drpProvince.Text.Trim();
  363. model.F_CITY = drpCity.Text.Trim();
  364. model.F_AREA = "";
  365. model.F_ROAD = "";
  366. model.F_HOUSING = "";
  367. model.F_WORKORDERFROM = "手工制单";
  368. //model.F_WORKORDERLEVELID = F_WORKORDERLEVELID;
  369. model.F_FILEFLAG = 0;
  370. model.F_CONTENT = txtTsContent.Value;
  371. model.F_REPAIRREQUEST = txtTsContent.Value;
  372. model.F_REPAIRMANID = 0;
  373. model.F_REPAIRMANNAME = txtTsName.Text;
  374. model.F_REPAIRMANPHONE = txtTsPhone.Text;
  375. if (hiddTsType.Value != "")
  376. {
  377. model.F_WORKORDERLEVELID = Convert.ToInt32(hiddTsType.Value);
  378. }
  379. LoginUser p_LoginUser = new LoginUser(this.Context);
  380. if (p_LoginUser.UserID != 0)
  381. {
  382. model.F_USERNAME = Server.UrlDecode(p_LoginUser.UserName);
  383. model.F_DEPTCODE = p_LoginUser.DeptId.ToString();
  384. model.F_EMPCODE = p_LoginUser.UserCode;
  385. model.F_DEPTID = p_LoginUser.DeptId;
  386. model.F_USERID = p_LoginUser.UserID;
  387. }
  388. model.F_CREATEBY = Convert.ToInt32(hfUserId.Value.Trim());
  389. model.F_CREATEDATE = DateTime.Now;
  390. model.F_RETURNVISITFLAG = 0;
  391. model.F_RETURNVISITSTATE = 0;
  392. model.F_RETURNVISITRESULT = 0;
  393. model.F_RETURNVISITCONTENT = "";
  394. model.F_DELETEFLAG = 0;
  395. model.F_ALLUSETIMES = 0;
  396. model.F_STARTTIME = DateTime.Now;
  397. model.F_OVERTIMES = 0;
  398. model.F_FORMID = 0;
  399. model.F_HASTENCOUNTS = 0;
  400. model.F_RANGEID = Convert.ToInt32(_flowid);
  401. model.F_RANGEX = 0;
  402. model.F_RANGEY = 0;
  403. model.F_INSTANCEID = Convert.ToInt32(instanceID);
  404. if (hiddCustomerId.Value.Trim() != "")
  405. {
  406. model.F_CUSTOMERID = Convert.ToInt32(hiddCustomerId.Value.Trim());
  407. }
  408. model.F_REPAIRCLOSEMANID = 0;
  409. model.F_REPAIRCLOSEMANNAME = "";
  410. model.F_REPAIRCLOSEREASONS = "";
  411. model.F_REPAIRCLOSEREPTID = 0;
  412. model.F_REPAIRCLOSEREPT = "";
  413. #endregion
  414. #region 关于超时时间
  415. SetWorkOrderBaseOverTime(typeid, model);
  416. #endregion
  417. int resorderbase = new BLL.T_Wo_WorkOrderBase().Add(model);//添加基本信息
  418. workorderid = resorderbase;
  419. if (resorderbase > 0)
  420. {
  421. bl = true;
  422. }
  423. else
  424. {
  425. bl = false;
  426. }
  427. }
  428. catch (Exception ex)
  429. {
  430. //InsertOptLogs("", "添加工单失败,错误信息:" + ex.Message, 2);
  431. MessageBoxToWindow("保存提示", "保存失败!" + ex.Message, "error");
  432. }
  433. return bl;
  434. }
  435. private void SaveHistoryInfo()
  436. {
  437. try
  438. {
  439. Common.LoginUser user = new Common.LoginUser(this.Context);
  440. Model.T_Wo_WorkOrderHistoryInfo modelHistoryInfo = new Model.T_Wo_WorkOrderHistoryInfo();
  441. string sql = "select * from T_Wo_WorkOrderHistory where F_INSTANCEID=" + instanceID + " and F_OPTUSERID=" + user.UserID + " order by F_HISTORYID desc";
  442. DataTable dt = HySoft.DBUtility.DbHelperSQL.Query(sql).Tables[0];
  443. if (dt.Rows.Count > 0)
  444. {
  445. modelHistoryInfo.F_HISTORYID = Convert.ToInt32(dt.Rows[0]["F_HISTORYID"]);
  446. }
  447. modelHistoryInfo.F_OPTUSERID = user.UserID;
  448. modelHistoryInfo.F_INSTANCEID = Convert.ToInt32(instanceID);
  449. modelHistoryInfo.F_OPTDATE = DateTime.Now;
  450. modelHistoryInfo.F_EXAMINETYPE = F_EXAMINETYPE.Text.Trim();
  451. BLL.T_Wo_WorkOrderHistoryInfo bll_addHistory = new BLL.T_Wo_WorkOrderHistoryInfo();
  452. bll_addHistory.Add(modelHistoryInfo);
  453. }
  454. catch { }
  455. }
  456. #region 获取超时时间
  457. /// <summary>
  458. /// 设置基本工单信息 超时时间,告警时间
  459. /// </summary>
  460. /// <param name="typeid">工单类型ID</param>
  461. /// <param name="model_orderbase">工单基本表Model</param>
  462. public void SetWorkOrderBaseOverTime(string typeid, Model.T_Wo_WorkOrderBase model_orderbase)
  463. {
  464. BLL.T_Wo_TypeAlarmDate bll_ala = new BLL.T_Wo_TypeAlarmDate();
  465. List<Model.T_Wo_TypeAlarmDate> list_ala = bll_ala.GetModelList(" F_WorkOrderTypeId='" + typeid
  466. + "' and F_DeleteFlag=0 ");
  467. if (list_ala != null && list_ala.Count > 0)
  468. {
  469. Model.T_Wo_TypeAlarmDate model_time = null;
  470. for (int i = 0; i < list_ala.Count; i++)
  471. { //如果有当前类型就取当前
  472. if (list_ala.Count > 1)
  473. {
  474. if (list_ala[i].F_IsMain == 1)
  475. {
  476. continue;
  477. }
  478. }
  479. model_time = list_ala[i];
  480. if (model_time != null)
  481. {
  482. int day = 0;
  483. int hour = 0;
  484. int minute = 0;
  485. switch (model_time.F_Cunit)
  486. {
  487. case 0://分钟
  488. minute = model_time.F_Ccount == null ? 0 : int.Parse(model_time.F_Ccount.ToString());
  489. break;
  490. case 1://小时
  491. hour = model_time.F_Ccount == null ? 0 : int.Parse(model_time.F_Ccount.ToString());
  492. break;
  493. case 2://天
  494. day = model_time.F_Ccount == null ? 0 : int.Parse(model_time.F_Ccount.ToString());
  495. break;
  496. default:
  497. break;
  498. }
  499. if (day == 0 && hour == 0 && minute == 0)
  500. model_orderbase.F_ASKFINISHTIME = null;
  501. else
  502. model_orderbase.F_ASKFINISHTIME = GetNoramlWorkTime(DateTime.Now, day, hour, minute);
  503. day = 0; hour = 0; minute = 0;//清值操作
  504. switch (model_time.F_Gunit)
  505. {
  506. case 0://分钟
  507. minute = model_time.F_Gcount == null ? 0 : int.Parse(model_time.F_Gcount.ToString());
  508. break;
  509. case 1://小时
  510. hour = model_time.F_Gcount == null ? 0 : int.Parse(model_time.F_Gcount.ToString());
  511. break;
  512. case 2://天
  513. day = model_time.F_Gcount == null ? 0 : int.Parse(model_time.F_Gcount.ToString());
  514. break;
  515. default:
  516. break;
  517. }
  518. if (day == 0 && hour == 0 && minute == 0)
  519. model_orderbase.F_REMAINDERTIME = null;
  520. else
  521. model_orderbase.F_REMAINDERTIME = GetNoramlWorkTime(DateTime.Now, day, hour, minute);
  522. }
  523. }
  524. }
  525. }
  526. /// <summary>
  527. /// 当前时间,换算成正常工作时间,并且Add 天时分
  528. /// </summary>
  529. /// <param name="timeStart">初始时间</param>
  530. /// <param name="days">增加的天数</param>
  531. /// <param name="hours">增加的小时</param>
  532. /// <param name="minutes">增加的分钟</param>
  533. /// <returns></returns>
  534. public DateTime GetNoramlWorkTime(DateTime timeStart, int days, int hours, int minutes)
  535. {
  536. timeStart = timeStart.AddDays(days);
  537. timeStart = timeStart.AddHours(hours);
  538. timeStart = timeStart.AddMinutes(minutes);
  539. return timeStart;
  540. }
  541. #endregion
  542. #region 弹出对话框
  543. /// <summary>
  544. /// 弹出对话框
  545. /// </summary>
  546. /// <param name="title"></param>
  547. /// <param name="content"></param>
  548. /// <param name="type"></param>
  549. public void MessageBoxToWindow(string content, string title, string type)
  550. {
  551. string script = "";
  552. switch (type)
  553. {
  554. case "error"://失败
  555. type = "error";
  556. script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "');</script>";
  557. break;
  558. case "success"://成功
  559. type = "success";
  560. hiddProvinceId.Value = "";
  561. script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "',TabCloseById);</script>";
  562. break;
  563. case "catch"://异常
  564. type = "warning";
  565. script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "');</script>";
  566. break;
  567. default:
  568. type = "question";
  569. break;
  570. }
  571. ClientScript.RegisterClientScriptBlock(this.GetType(), "", script);
  572. }
  573. #endregion
  574. #region 客户信息
  575. private Model.T_Cus_CustomerBase GetCustomerModel()
  576. {
  577. Model.T_Cus_CustomerBase _model = new Model.T_Cus_CustomerBase();
  578. try
  579. {
  580. if (hiddCustomerId.Value != "" && hiddCustomerId.Value != "0")
  581. {
  582. _model.F_CustomerId = Convert.ToInt32(hiddCustomerId.Value);
  583. _model = new BLL.T_Cus_CustomerBase().GetModel(Convert.ToInt32(hiddCustomerId.Value));
  584. }
  585. else
  586. {
  587. _model.F_CustomerCode = "KHBH" + DateTime.Now.ToString("yyyyMMddHHmmss");// txtCustomerCode.Text.Trim();
  588. }
  589. _model.F_CustomerName = txtCustomerName.Text.Trim();
  590. if (hiddSeriveDeptId.Value != "")
  591. {
  592. _model.F_ServiceDeptID = Convert.ToInt32(hiddSeriveDeptId.Value);
  593. }
  594. _model.F_ServiceDept = drpServiceDept.Text;
  595. if (hiddProvinceId.Value != "")
  596. {
  597. _model.F_RegionId = Convert.ToInt32(hiddProvinceId.Value);
  598. }
  599. _model.F_Province = drpProvince.Text;
  600. if (hiddCityId.Value != "")
  601. {
  602. _model.F_CityID = Convert.ToInt32(hiddCityId.Value);
  603. }
  604. _model.F_City = drpCity.Text;
  605. _model.F_Telephone = drpTelephone.Text;
  606. _model.F_Mobile = drpMobile.Text;
  607. _model.F_ChargeTelephone = drpChargeTelephone.Text;
  608. return _model;
  609. }
  610. catch
  611. {
  612. return null;
  613. }
  614. }
  615. #endregion
  616. #region 发送短信
  617. public void SetSMS(string userid)
  618. {
  619. try
  620. {
  621. Model.T_SMS_SendSMSTask model = new Model.T_SMS_SendSMSTask();
  622. BLL.T_SMS_SendSMSTask bll = new BLL.T_SMS_SendSMSTask();
  623. DataTable dt1 = new BLL.T_Sys_UserAccount().GetList(" F_UserId=" + userid + "").Tables[0];
  624. if (dt1.Rows.Count > 0)
  625. {
  626. model.TelNum = dt1.Rows[0]["F_Mobile"].ToString();
  627. model.F_Name = dt1.Rows[0]["F_UserName"].ToString();
  628. }
  629. if (txtCustomerName.Text.Trim() != "")
  630. {
  631. model.Content = txtCustomerName.Text;
  632. }
  633. else
  634. {
  635. model.Content = "客户单位未知";
  636. }
  637. if (txtTsName.Text.Trim() != "")
  638. {
  639. model.Content += ",联系人:" + txtTsName.Text.Trim();
  640. }
  641. else { model.Content += ",联系人:未知"; }
  642. if (txtTsPhone.Text.Trim() != "")
  643. {
  644. model.Content += ",电话:" + txtTsPhone.Text.Trim();
  645. }
  646. else { model.Content += ",电话:未知"; }
  647. if (txtTsContent.InnerText.Trim() != "")
  648. {
  649. model.Content += ",来电内容:" + txtTsContent.InnerText.Trim() + "。";
  650. }
  651. else { model.Content += ",来电内容:为空。"; }
  652. model.SendTime = DateTime.Now;
  653. model.LastSentTime = DateTime.Now;
  654. model.CommitTime = DateTime.Now;
  655. DataTable dt2 = new BLL.T_Sys_UserAccount().GetList(" F_RoleId in (SELECT F_RoleId FROM T_Sys_RoleFunction where F_FunctionId in(select F_FunctionId from T_Sys_ModuleFunctions where F_FunctionCode='jsdx')) and F_UserId=" + userid + "").Tables[0];
  656. if (dt2.Rows.Count > 0)
  657. {
  658. bll.Add(model);
  659. }
  660. }
  661. catch { }
  662. }
  663. #endregion
  664. #region 咨询发送短信
  665. public void ZXSetSMS(string userid)
  666. {
  667. try
  668. {
  669. if (userid != "" && userid != "0")
  670. {
  671. Model.T_SMS_SendSMSTask model = new Model.T_SMS_SendSMSTask();
  672. BLL.T_SMS_SendSMSTask bll = new BLL.T_SMS_SendSMSTask();
  673. DataTable dt1 = new BLL.T_Sys_UserAccount().GetList(" F_UserId=" + userid + "").Tables[0];
  674. if (dt1.Rows.Count > 0)
  675. {
  676. model.TelNum = dt1.Rows[0]["F_Mobile"].ToString();
  677. model.F_Name = dt1.Rows[0]["F_UserName"].ToString();
  678. }
  679. if (txtCustomerName.Text.Trim() != "")
  680. {
  681. model.Content = txtCustomerName.Text;
  682. }
  683. else
  684. {
  685. model.Content = "客户单位未知";
  686. }
  687. //if (txtZxName.Text.Trim() != "")
  688. //{
  689. // model.Content += ",联系人:" + txtZxName.Text.Trim();
  690. //}
  691. //else { model.Content += ",联系人:未知"; }
  692. //if (txtZxPhone.Text.Trim() != "")
  693. //{
  694. // model.Content += ",电话:" + txtZxPhone.Text.Trim();
  695. //}
  696. //else { model.Content += ",电话:未知"; }
  697. //if (txtZxContent.InnerText.Trim() != "")
  698. //{
  699. // model.Content += ",来电内容:" + txtZxContent.InnerText.Trim() + "。";
  700. //}
  701. //else { model.Content += ",来电内容:为空。"; }
  702. model.SendTime = DateTime.Now;
  703. model.LastSentTime = DateTime.Now;
  704. model.CommitTime = DateTime.Now;
  705. bll.Add(model);
  706. }
  707. }
  708. catch { }
  709. }
  710. #endregion
  711. }
  712. }