public ActionResult signingProcess(FORM_IT_01Model fORM_IT_01s) { var formID = Session["formName"].ToString(); var newCode = new NewCode(); //fORM_IT_01.AppNo = DateTime.Now.ToString("yyyyMMddHHmmss"); //Session["APPNO"] = fORM_IT_01.AppNo; fORM_IT_01s.FormID = newCode.getFormID(formID); fORM_IT_01s.AppNo = Session["APPNO"].ToString(); string sqlQuery = @"select * from SubmitSign where FormID = '" + fORM_IT_01s.FormID + "' order by SignNo asc"; DataTable tbSignProcess = new DataTable(); tbSignProcess = dbHelpers.DoSQLSelect(sqlQuery); string signEmpNo1 = ""; string SignName1 = ""; string statusName1 = ""; int step1 = 0; string agent = ""; if (tbSignProcess.Rows.Count > 0) { for (int i = 0; i < tbSignProcess.Rows.Count; i++) { step1 = i; statusName1 = tbSignProcess.Rows[i]["SignName"].ToString(); signEmpNo1 = fORM_IT_01s.approvalApps[i].signEmpNo.ToString(); SignName1 = fORM_IT_01s.approvalApps[i].SignName.ToString(); newCode.insertListSign(fORM_IT_01s.AppNo, signEmpNo1, SignName1, statusName1, step1); } } return(View("appITForm02")); }
public ActionResult Index(FORM_IT_01Model conModel) { bool checkReasonFlag = false; setViewFactoryDec(); try { var dao = new AccountDao(); conModel.AppNo = DateTime.Now.ToString("yyyyMMddHHmmss") + GenerateRandom(2); switch (conModel.Title15Content) { case "Esign system 2.0": { using (SqlConnection conn = new SqlConnection(@"Data Source=10.224.81.131,3000;Initial Catalog=esign;Persist Security Info=True;User ID=sa;Password=foxconn168!!")) { int rowAff; if (conn.State != ConnectionState.Open) { conn.Open(); } using (SqlTransaction trans = conn.BeginTransaction()) { string strQuery = @"ngac nhien khong baby"; //int checkAcc = dao.Login2(conModel.empID.Trim()); //if(checkAcc == 1) //{ // string role=""; // if (conModel.role1) role += "USER;"; // if (conModel.role2) role += "MANAGERMENTUSER;"; // if (conModel.role3) role += "ITNETWORK;"; // if (conModel.role4) role += "ITMANAGER;"; // strQuery = @"update Account set note='"+role+"' where UserID='"+conModel.empID+"'"; // SqlCommand cmd = new SqlCommand(strQuery, conn, trans); // rowAff = cmd.ExecuteNonQuery(); // if(rowAff > 0) // { // checkReasonFlag = true; // } //} //else //{ // string role = ""; // if (conModel.role1) role += "USER;"; // if (conModel.role2) role += "MANAGERMENTUSER;"; // if (conModel.role3) role += "ITNETWORK;"; // if (conModel.role4) role += "ITMANAGER;"; // strQuery = @"insert into Account(userid,username,telephone,Email,note) values(@userid,@username,@telephone,@Email,@note);"; // SqlCommand cmd = new SqlCommand(strQuery, conn, trans); // SqlParameter[] param = new SqlParameter[5]; // param.SetValue(new SqlParameter("userid", conModel.empID), 0); // param.SetValue(new SqlParameter("userid", conModel.empID), 0); // param.SetValue(new SqlParameter("userid", conModel.empID), 0); // param.SetValue(new SqlParameter("userid", conModel.empID), 0); // rowAff = cmd.ExecuteNonQuery(); // if (rowAff > 0) // { // checkReasonFlag = true; // } //} string role = ""; if (conModel.role11) { role += "USER;"; } if (conModel.role12) { role += "MANAGERMENTUSER;"; } if (conModel.role13) { role += "ITNETWORK;"; } if (conModel.role14) { role += "ITMANAGER;"; } strQuery = @"insert into RegisterAccount(EmpID,empName,EmpDePart,EmpPhone,EmpCost,EmpSys,EmpRole,EmpFac,EmpLocation,AppNoReg,EmpMail) values (@EmpID,@empName,@EmpDePart,@EmpPhone,@EmpCost,@EmpSys,@EmpRole,@EmpFac,@EmpLocation,@AppNoReg,@EmpMail);"; SqlCommand cmd = new SqlCommand(strQuery, conn, trans); SqlParameter[] param = new SqlParameter[11]; param.SetValue(new SqlParameter("EmpID", conModel.empID), 0); param.SetValue(new SqlParameter("empName", conModel.empName), 1); param.SetValue(new SqlParameter("EmpDePart", conModel.Title3Content), 2); param.SetValue(new SqlParameter("EmpPhone", conModel.Title2Content), 3); param.SetValue(new SqlParameter("EmpCost", conModel.Title4Content), 4); param.SetValue(new SqlParameter("EmpSys", conModel.Title15Content), 5); param.SetValue(new SqlParameter("EmpRole", role), 6); param.SetValue(new SqlParameter("EmpFac", conModel.Title14Content), 7); param.SetValue(new SqlParameter("EmpLocation", conModel.Title5Content), 8); param.SetValue(new SqlParameter("AppNoReg", conModel.AppNo.Trim()), 9); param.SetValue(new SqlParameter("EmpMail", conModel.Title1Content), 10); cmd.Parameters.AddRange(param); rowAff = cmd.ExecuteNonQuery(); if (rowAff > 0) { checkReasonFlag = true; } if (checkReasonFlag) { // thiet lap luu trinh ky don string[] managerDep = itContr.checkManager(conModel.empID).Split(';'); managerDep = managerDep.Where(x => !string.IsNullOrEmpty(x)).ToArray(); string[] managerDepTitle = new string[managerDep.Length]; if (managerDep.Length > 1) { managerDepTitle[0] = "課級 / Cấp phòng"; managerDepTitle[1] = "部級 / Cấp bộ phận"; } else { managerDepTitle[0] = " 部級 / Cấp bộ phận"; } string[] managerIT = { "V0903271" }; string[] managerITtitle = { "會簽IT課長 / Trưởng phòng IT " }; string[] signer = new string[managerDep.Length + managerIT.Length + 2]; string[] signerTitle = new string[managerDep.Length + managerIT.Length + 2]; signer[0] = conModel.empID; signerTitle[0] = "申請人 / Người xin đơn"; for (int i = 0; i < signer.Length; i++) { if (signer[i] == null) { for (int j = 0; j < managerDep.Length; j++) { signer[i + j] = managerDep[j].ToString(); signerTitle[i + j] = managerDepTitle[j].ToString(); } break; } } for (int i = 0; i < signer.Length; i++) { if (signer[i] == null) { for (int j = 0; j < managerIT.Length; j++) { signer[i + j] = managerIT[j].ToString(); signerTitle[i + j] = managerITtitle[j].ToString(); } break; } } for (int i = 0; i < signer.Length; i++) { if (signer[i] == null) { signer[i] = "V0957033"; signerTitle[i] = "結案單位IT / IT kết án "; break; } } string name = ""; var session = (UserLogin)Session[CommonConstants.USER_SESSION]; var empCreate = session.UserID.Trim(); for (int i = 0; i < signer.Length; i++) { name = itContr.getName(signer[i].Trim().ToString()); nCode.insertListSign(conModel.AppNo, signer[i].Trim().ToString(), name, signerTitle[i].ToString(), i); } string signerName = itContr.getName(signer[1].ToString()); nCode.insertAppData(conModel.AppNo, signerTitle[1].ToString(), conModel.empName, signerName, DateTime.Now.ToString("yyyy/MM/dd HH:mm"), signer[1].ToString(), 2, 1, conModel.empID, "Register Account", empCreate); sb.f_submit_yellow("Submit", conModel.AppNo, 2, conModel.empName, conModel.empID, 0); sendM.insertSenmail(signer[1].Trim().ToString(), conModel.AppNo, "Register Account", signer[0].Trim().ToString(), "文件電子簽核申請單等待簽核", "Register Account"); sendM.insertSenmail(signer[0].Trim().ToString(), conModel.AppNo, "Register Account", signer[0].Trim().ToString(), "提交文件表格电子批准申请", conModel.Title1Content); } if (checkReasonFlag == true) { trans.Commit(); } else { trans.Rollback(); } if (conn.State == ConnectionState.Open) { conn.Close(); } } } break; } default: { break; } } } catch { } if (checkReasonFlag) { return(RedirectToAction("ListSoftWare", "APP_ESIGN")); } else { return(View(conModel)); } }