//complete old /* public string getRequest(string person_id) { Request q = new Request(); try { string constr = WebConfigurationManager.ConnectionStrings["Dbconnection"].ConnectionString; SqlConnection con = new SqlConnection(constr); con.Open(); string sqlproject = "SELECT * FROM Request_Title WHERE AcceptanceID = '" + person_id + "'"; SqlCommand qrproject = new SqlCommand(sqlproject, con); SqlDataReader reader = qrproject.ExecuteReader(); if (reader.Read()) { q.ProjID = reader["ProjID"].ToString(); q.ReqID = reader["ReqID"].ToString(); q.Date = reader["Date"].ToString(); } reader.Close(); con.Close(); q.code = 0; q.msg = "OK"; } catch { q.code = 9; q.msg = "Database Error"; } return JsonConvert.SerializeObject(q); }*/ //complete public string approveProject(string project_temp, string state, string status) { updateState(project_temp, state, status); string constr = WebConfigurationManager.ConnectionStrings["Dbconnection"].ConnectionString; SqlConnection con = new SqlConnection(constr); con.Open(); string sql = "DELETE FROM Request_Title WHERE ProjID='" + project_temp + "'"; SqlCommand cmdProgress = new SqlCommand(sql, con); cmdProgress.ExecuteNonQuery(); con.Close(); ResponseMsg m = new ResponseMsg(); if (sendEmail()) { m.code = 0; m.msg = "OK"; m.value = "Send Success"; } else { m.code = -1; m.msg = "mail server Error"; m.value = ""; } return JsonConvert.SerializeObject(m); }
public JsonResult GetClosingQty(int ProductID, int ShadeID, string PackingIDs) { ResponseMsg response = new ResponseMsg(); var packings = StockLogic.GetClosingQty(ProductID, ShadeID, PackingIDs); if (packings != null && packings.Count() > 0) { response.IsSuccess = true; response.ResponseValue = packings; } return(Json(response, JsonRequestBehavior.AllowGet)); }
public ActionResult Reopen(string ID) { ResponseMsg response = new ResponseMsg(); if (Convert.ToInt32(ID) > 0) { OrderLogic.ReopenOrder(ID); response.IsSuccess = true; response.ResponseValue = ""; } return(Json(response, JsonRequestBehavior.AllowGet)); }
public ActionResult UpdateProfile(Employee employee) { ResponseMsg response = new ResponseMsg(); employee.CreatedBy = employee.UpdatedBy = currUser.ID; employee.Password = StringCipher.Decrypt(currUser.Password); employee.Type = currUser.Type; EmployeeLogic.AddEmployee(employee); Session["User"] = EmployeeLogic.GetEmployeeByID(currUser.ID).FirstOrDefault(); response.IsSuccess = true; return(Json(response)); }
public JsonResult Delete(string ID) { ResponseMsg response = new ResponseMsg(); if (Convert.ToInt32(ID) > 0) { PackingLogic.DeletePackingByID(ID); response.IsSuccess = true; response.ResponseValue = ""; } return(Json(response, JsonRequestBehavior.AllowGet)); }
public void Handle(Msg message) { _action[message.MsgType](message); if (((ActorCell)Context).NumberOfMessages == 0) { var msgx = new ResponseMsg { Msgs = _users }; Console.WriteLine("publish Count:" + _users.Count()); _rendererActor.Tell(msgx); } }
public void Start(ModelLibrary library) { IPAddress address = IPAddress.Parse("127.0.0.1"); TcpListener listener = new TcpListener(address, 12345); IsRunning = true; listener.Start(); while (IsRunning) { TcpClient client = listener.AcceptTcpClient(); Console.WriteLine("Connection accepted from " + client.Client.RemoteEndPoint); using (StreamReader reader = new StreamReader(client.GetStream())) using (StreamWriter writer = new StreamWriter(client.GetStream())) { // format to json IFormatter formatter = new BinaryFormatter(); while (IsRunning) { Console.WriteLine("Waiting for messages..."); //IdentificationRequest request = (IdentificationRequest)formatter.Deserialize(stream); var request = JsonConvert.DeserializeObject <RequestMsg>(reader.ReadLine()); Bitmap bmp = new Bitmap(request.Width, request.Height, PixelFormat.Format8bppIndexed); var rect = new Rectangle(0, 0, request.Width, request.Height); var bmpData = bmp.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed); var ptr = bmpData.Scan0; for (var i = 0; i < request.Height; i++) { Marshal.Copy(request.Pixels, i * request.Width, ptr, request.Width); ptr += bmpData.Stride; } bmp.UnlockBits(bmpData); string identifiedObject = library.IdentifyObject(bmp); var response = new ResponseMsg() { ObjectName = identifiedObject, Success = true }; var responseJson = JsonConvert.SerializeObject(response); writer.WriteLine(responseJson); writer.Flush(); } } } }
protected override string ProcessChange() { if (this.templateNode.Attributes.Count == 1 && this.templateNode.Attributes[0].Name.ToLower() == "to") { string toOpenid = this.templateNode.Attributes[0].Value; this.user.ToUserID = toOpenid; StringBuilder templateResult = new StringBuilder(); foreach (XmlNode childNode in this.templateNode.ChildNodes) { if (childNode.Name == "get") { if (childNode.Attributes.Count == 1 && childNode.Attributes[0].Name.ToLower() == "name" && this.user.Predicates.containsSettingCalled(childNode.Attributes[0].Value)) { templateResult.Append(this.user.Predicates.grabSetting(childNode.Attributes[0].Value)); } } else if (childNode.Name == "star") { if (childNode.Attributes.Count == 1 && childNode.Attributes[0].Name.ToLower() == "index") { int index = Convert.ToInt32(childNode.Attributes[0].Value); index--; if ((index >= 0) & (index < this.query.InputStar.Count)) { templateResult.Append(this.query.InputStar[index]); } } } else { templateResult.Append(childNode.InnerText); } } string text = templateResult.ToString(); if (!string.IsNullOrEmpty(text)) { //发送客服消息 ThreadPool.QueueUserWorkItem(delegate(object obj) { ResponseMsg msg = new ResponseMsg(); msg.ToUser = toOpenid; msg.MsgType = "text"; msg.Content = text; this.bot.wechat.Response(msg); msg.Content = "connect#" + this.user.UserID; this.bot.wechat.Response(msg); }); } } return(string.Empty); }
private async void getBalance(int year, int month) { using (var cl = new HttpClient()) { var formcontent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("owner_id", App.owner_ID), new KeyValuePair <string, string>("month", year + "/" + month + "/1") }); try { var request = await cl.PostAsync(Constants.SERVER_BASE_URL + "get_month_calculation", formcontent); request.EnsureSuccessStatusCode(); var response = await request.Content.ReadAsStringAsync(); ResponseMsg resultMsg = JsonConvert.DeserializeObject <ResponseMsg>(response); if (resultMsg.resp.Equals("success")) { ResponseData resultData = JsonConvert.DeserializeObject <ResponseData>(response); string balance_month = $"{year}{"年"}{month}{"月の収支"}"; lbl_balance.Text = balance_month; lbl_income.Text = resultData.income; lbl_spend.Text = resultData.outcome; var current_balance = Convert.ToInt32(resultData.income) - Convert.ToInt32(resultData.outcome); if (current_balance >= 0) { balance_color = Color.Black; } else { balance_color = Color.DarkRed; } lbl_current_balance.Text = current_balance.ToString(); lbl_current_balance.TextColor = balance_color; } else { await DisplayAlert("", resultMsg.resp, "はい"); } } catch { await DisplayAlert("", Constants.NETWORK_ERROR, "はい"); } } }
/// <summary> /// Handles request synchronously in the context of the calling thread. Returns NULL for one-way calls /// </summary> public ResponseMsg HandleRequestFailure(FID reqID, bool oneWay, Exception failure, object bindingSpecCtx) { if (oneWay) { return(null); } var red = new WrappedExceptionData(failure); var response = new ResponseMsg(reqID, red); response.__SetBindingSpecificContext(bindingSpecCtx); return(response); }
private async void checkRegisterInfo() { loadingbar.IsRunning = true; using (var cl = new HttpClient()) { var formcontent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>(Constants.OWNER_ID, App.owner_ID), new KeyValuePair <string, string>(Constants.ESTATE_NAME, building_name.Text), new KeyValuePair <string, string>(Constants.RENTAL_INCOME, rental_income.Text), new KeyValuePair <string, string>(Constants.ADMIN_EXPENSES, admin_expenses.Text), new KeyValuePair <string, string>(Constants.REPAIR_RESERVE, repair_reserve.Text), new KeyValuePair <string, string>(Constants.AGENCY_FEE, agency_fee.Text), new KeyValuePair <string, string>(Constants.estate_property_tax, property_tax.Text) }); try { var request = await cl.PostAsync(Constants.SERVER_ZERO_REGIST_URL, formcontent); request.EnsureSuccessStatusCode(); var response = await request.Content.ReadAsStringAsync(); ResponseMsg resultMsg = JsonConvert.DeserializeObject <ResponseMsg>(response); if (resultMsg.resp.Equals("success")) { loadingbar.IsRunning = false; ResponseData resultData = JsonConvert.DeserializeObject <ResponseData>(response); //App.estate_num += 1; await Navigation.PushAsync(new ZeroRegisterAlert("管理物件追加")); } else { loadingbar.IsRunning = false; await DisplayAlert("", resultMsg.resp, "はい"); } } catch { loadingbar.IsRunning = false; await DisplayAlert("", Constants.NETWORK_ERROR, "はい"); } } }
public ActionResult Delete(string ID) { ResponseMsg response = new ResponseMsg(); if (Convert.ToInt32(ID) > 0) { if (!ProductLogic.DeleteProductByID(ID)) { response.IsSuccess = true; response.ResponseValue = ""; } } return(Json(response, JsonRequestBehavior.AllowGet)); }
public ActionResult DeleteConversion(int ID) { ResponseMsg response = new ResponseMsg(); if (ID > 0) { if (!ProductLogic.DeleteConversionByID(ID)) { response.IsSuccess = true; response.ResponseValue = ""; } } return(Json(response, JsonRequestBehavior.AllowGet)); }
private async void Btn_send_comment_Clicked(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(editor_comment.Text)) { using (var cl = new HttpClient()) { loadingbar.IsRunning = true; var formcontent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("comment_contents", System.Net.WebUtility.UrlEncode(editor_comment.Text)), new KeyValuePair <string, string>("comment_writer_id", "o_" + App.owner_ID), new KeyValuePair <string, string>("comment_news_id", comment_news_id) }); try { var request = await cl.PostAsync(Constants.SERVER_REGIST_COMMENT_URL, formcontent); request.EnsureSuccessStatusCode(); var response = await request.Content.ReadAsStringAsync(); ResponseMsg resultMsg = JsonConvert.DeserializeObject <ResponseMsg>(response); if (resultMsg.resp.Equals("success")) { loadingbar.IsRunning = false; editor_comment.Text = string.Empty; await PopupNavigation.Instance.PopAsync(); } else { loadingbar.IsRunning = false; await DisplayAlert("", resultMsg.resp, "はい"); } } catch { loadingbar.IsRunning = false; await DisplayAlert("", Constants.NETWORK_ERROR, "はい"); await PopupNavigation.Instance.PopAsync(); } } } }
public ActionResult Add(Party partyModel) { ResponseMsg response = new ResponseMsg(); partyModel.CreatedBy = partyModel.UpdatedBy = currUser.ID; if (PartyLogic.SaveParty(partyModel)) { response.IsSuccess = true; } else { response.IsSuccess = false; } return(Json(response)); }
public ActionResult Add(Order order) { ResponseMsg response = new ResponseMsg(); order.CreatedBy = order.UpdatedBy = currUser.ID; if (OrderLogic.SaveOrder(order)) { response.IsSuccess = true; } else { response.IsSuccess = false; } return(Json(response)); }
public ActionResult QCDone(string ID, List <BillOfMaterialLabParameters> paramValue) { ResponseMsg response = new ResponseMsg(); if (QCLogic.Done(ID, paramValue)) { var fileName = QCLogic.PrintQCSlip(paramValue, Server.MapPath(ConfigurationManager.AppSettings["ReportFolderPath"]), Convert.ToInt32(ID), currUser.Name); if (!string.IsNullOrEmpty(fileName)) { response.IsSuccess = true; response.ResponseValue = ConfigurationManager.AppSettings["ReportFolderPath"].Replace("~", "").Trim() + fileName; } } return(Json(response)); }
public IHttpActionResult PostNCFXML([FromBody] Services.DataParams param) { ResponseMsg response = null; try { response = DbService.executeTransaction(param.TipoSecuencia, param.Sistema, param.NumeroFactura); } catch (Exception ex) { return(InternalServerError(ex)); } return(Ok(Serialize(response))); }
public ActionResult GetProductShadesAndPackings(string ID) { ResponseMsg response = new ResponseMsg(); if (!string.IsNullOrEmpty(ID) && Convert.ToInt32(ID) > 0) { response.IsSuccess = true; response.ResponseValue = new { Shades = ShadeLogic.GetShadeByProductID(Convert.ToInt32(ID)), Packings = PackingLogic.GetPackingByProductID(Convert.ToInt32(ID)) }; } return(Json(response, JsonRequestBehavior.AllowGet)); }
public JsonResult GetGroupType(int GroupID) { ResponseMsg response = new ResponseMsg(); if (GroupID > 0) { var group = ProductGroupLogic.GetProductGroupByID(GroupID); if (group != null) { response.IsSuccess = true; response.ResponseValue = group; } } return(Json(response, JsonRequestBehavior.AllowGet)); }
public ActionResult Add(Product productModel) { ResponseMsg response = new ResponseMsg(); productModel.CreatedBy = productModel.UpdatedBy = currUser.ID; if (ProductLogic.SaveProduct(productModel)) { response.IsSuccess = true; } else { response.IsSuccess = false; } return(Json(response)); }
public ActionResult Add(Inward inward) { ResponseMsg response = new ResponseMsg(); inward.CreatedBy = inward.UpdatedBy = currUser.ID; if (InwardLogic.SaveInward(inward)) { response.IsSuccess = true; } else { response.IsSuccess = false; } return(Json(response)); }
public AgentController() { agentConfig = new AgentConfig(); string sessionName = WebConfigurationManager.AppSettings["loginSessionName"]; if (HttpContext.Current.Session[sessionName] == null) { MsgEntity r; ResponseMsg.SetEntity(out r, 4102); HttpContext.Current.Response.Write(JsonHelper.ScriptSerialize(r, false)); HttpContext.Current.Response.End(); } }
public ResponseMsg <bool> Exists(Expression <Func <TEntity, bool> > filterExpression) { ResponseMsg <int> responseMsg = Count(filterExpression); ResponseMsg <bool> response = new ResponseMsg <bool>(); if (responseMsg.StatusCode == (int)StatusCodeEnum.Success) { response = response.Ok(responseMsg.Data > 0); } else { response = response.Error(new Exception(responseMsg.StatusMsg)); } return(response); }
private async void SendZeroInfo() { using (var cl = new HttpClient()) { loadingbar.IsRunning = true; var formcontent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>(Constants.OWNER_ID, App.owner_ID), new KeyValuePair <string, string>(Constants.ESTATE_NAME, Global.zero_estate_name), new KeyValuePair <string, string>(Constants.ESTATE_ADDRESS, Global.zero_estate_address), new KeyValuePair <string, string>(Constants.ESTATE_ROOM_NUMBER, Global.zero_estate_address), new KeyValuePair <string, string>(Constants.ZERO_COMPANY, Global.zero_company), new KeyValuePair <string, string>(Constants.ZERO_END_DATE, Global.zero_end_date), new KeyValuePair <string, string>(Constants.ZERO_TYPE, Global.zero_type), new KeyValuePair <string, string>(Constants.ZERO_AGENCY_NAME, Global.zero_agency_name), new KeyValuePair <string, string>(Constants.ZERO_AGENCY_PHONE, Global.zero_agency_phone), }); try { var request = await cl.PostAsync(Constants.SERVER_ZERO_REGIST_URL, formcontent); request.EnsureSuccessStatusCode(); var response = await request.Content.ReadAsStringAsync(); ResponseMsg resultMsg = JsonConvert.DeserializeObject <ResponseMsg>(response); if (resultMsg.resp.Equals("success")) { loadingbar.IsRunning = false; App.owner_estate_id += resultMsg.estate_id + ","; } else { loadingbar.IsRunning = false; await DisplayAlert("", resultMsg.resp, "はい"); } } catch { loadingbar.IsRunning = false; await DisplayAlert("", Constants.NETWORK_ERROR, "はい"); } } }
public async Task <IHttpActionResult> DeteletAccount(int id) { bool check = await DeleteAccount.FuncDeleteAccount(id); ResponseMsg messages = new ResponseMsg(); if (check) { messages.message = "Delete account successful."; return(Ok(messages)); } else { return(BadRequest("Error deleted account.")); } }
public ActionResult ChangePassword(string NewPassword) { ResponseMsg response = new ResponseMsg(); try { clsBusinessLogic.ChangePassword(NewPassword, ((User)Session["CurrentUser"]).Id.ToString()); response.IsSuccess = true; } catch (Exception ex) { response.IsSuccess = false; response.ResponseValue = "Error : " + ex.Message; } return(Json(response)); }
public ResponseMsg <TEntity> Single(Expression <Func <TEntity, bool> > filterExpression) { ResponseMsg <int> response = Count(filterExpression); if (response.StatusCode == (int)StatusCodeEnum.Success) { if (response.Data > 1 || response.Data == 0) { throw new Exception("The query does not return exactly one item."); } return(First(filterExpression)); } ResponseMsg <TEntity> responseMsg = new ResponseMsg <TEntity>(); return(responseMsg.Error(new Exception(response.StatusMsg))); }
public ActionResult Add(Dispatch dispatch) { ResponseMsg response = new ResponseMsg(); dispatch.CreatedBy = ((Employee)Session["User"]).ID; if (DispatchLogic.SaveDispatch(dispatch)) { response.IsSuccess = true; response.ResponseValue = DispatchLogic.GetDispatchByDONo(dispatch.DONo); } else { response.IsSuccess = false; } return(Json(response)); }
public ActionResult SaveYagnaMember(YagnaMember member) { ResponseMsg response = new ResponseMsg(); try { int memberId = clsBusinessLogic.SaveYagnaMember(member); response.IsSuccess = true; } catch (Exception ex) { response.IsSuccess = false; response.ResponseValue = "Error : " + ex.Message; } return(Json(response)); }
public ResponseMsg <int> Add <TModel>(TModel entity, IDbTransaction transaction = null) where TModel : BaseEntity, new() { ResponseMsg <int> responseMsg = new ResponseMsg <int>(); Tuple <string, IDbDataParameter[]> addSql = null; DynamicParameters args = new DynamicParameters(); string idtName = string.Empty; int addResult = 0; try { addSql = _generateSql.GenerateInsertSqlTextAndParam(); args = new DynamicParameters(entity); if (addSql.Item2 != null) { addSql.Item2.ForAll(p => args.Add(p.ParameterName, p.Value, p.DbType, p.Direction)); } idtName = _generateSql.GetIdentityFields();//获得自增长列名 if (!string.IsNullOrEmpty(idtName)) { addResult = _connection.ExecuteScalar <int>(addSql.Item1, args, transaction); var dic = new Dictionary <string, object> { { idtName, addResult } }; ReflectionHelper.SetPropertyValue(entity, dic);//设置自增长id的值 } else { addResult = _connection.Execute(addSql.Item1, args, transaction); } if (addResult > 0) { responseMsg = responseMsg.Ok(addResult); } } catch (Exception ex) { _recordInvokeSql.RecordSql <TModel>(entity, addSql.Item1, idtName); responseMsg = responseMsg.Error(ex); LogManage.Error.Debug(ex.Message); } finally { _connection.Dispose(); } return(responseMsg); }
protected override async Task<byte[]> ProcessRequest(byte[] reqData) { var t = new TaskCompletionSource<byte[]>(); var requestMsg = MsgPackTool.GetMsg<RequestMsg>(reqData); var requestType = requestMsg.RequestType; var requestObj = MsgPackTool.GetMsg(requestType, requestMsg.RequestObjectData); var resMsg = new ResponseMsg(); resMsg.IsError = false; RpcServiceFuncInfo funcInfo; if (!_serviceFuncs.TryGetValue(requestType, out funcInfo)) { Logger.Error("Not found RequestType func: {0}", requestType); return await t.Task; } var info = _serviceFuncs[requestType]; var method = info.Method; byte[] executeResult = null; if (method != null) { try { var result = method.Invoke(_rpcService, new[] { requestObj }); if (result != null) executeResult = MsgPackTool.GetBytes(method.ReturnType, result); } catch (Exception e) { resMsg.IsError = true; resMsg.ErrorMessage = string.Format("[ERROR]Method '{0}' Exception: {1}", requestObj, e); Logger.Error(resMsg.ErrorMessage); } } else { resMsg.IsError = true; resMsg.ErrorMessage = string.Format("[ERROR]Not found method: {0}", requestObj); Logger.Error(resMsg.ErrorMessage); } resMsg.Data = executeResult; t.SetResult(MsgPackTool.GetBytes(resMsg)); return await t.Task; }
/* public string sync_form_three(string person_id) { getNameProject(person_id); }*/ public string send_form_three(string person_id, string project_scrop, bool send_approve) { ResponseMsg r = new ResponseMsg(); try { project_id = getProjectID(person_id); string constr = WebConfigurationManager.ConnectionStrings["Dbconnection"].ConnectionString; SqlConnection con = new SqlConnection(constr); con.Open(); string send = ""; send = "UPDATE project SET Scope='" + project_scrop + "'"; send += "WHERE ProjID ='" + getProjectID(person_id) + "'"; SqlCommand cmdUpdate = new SqlCommand(send, con); cmdUpdate.ExecuteNonQuery(); if (send_approve) { updateState(getProjectID(person_id), "3", "2"); //con.Open(); string sqlRequest = ""; sqlRequest = "SET IDENTITY_INSERT Request_Title ON "; sqlRequest += "INSERT INTO Request_Title (Req_TitleiD,ReqID,ProjID,ApplicantID,AcceptanceID,Date) "; sqlRequest += "VALUES ( '" + getID("Req_TitleiD", "Request_Title") + "','3','" + project_id + "','" + person_id + "','" + getAdviser() + "', GETDATE())"; SqlCommand cmdInsert = new SqlCommand(sqlRequest, con); cmdInsert.ExecuteNonQuery(); r.code = 0; r.msg = "Insert"; r.value = ""; } else { updateState(person_id, "3", "1"); r.code = 0; r.msg = "OK"; r.value = ""; } } catch { r.code = 9; r.msg = "Database Error"; r.value = ""; } return JsonConvert.SerializeObject(r); }
public string send_form_one(string project_name_th, string project_name_en, string member_one, string member_two, string member_three, string project_adviser, string project_co_adviser, string project_committee, bool send_approve) { ResponseMsg m = new ResponseMsg(); try { string member = countMember(member_one, member_two, member_three); if (saveProject(project_name_th, project_name_en, "null", member)) { if (createRelation(project_id, member_one, "0")) { m.code = 0; m.msg = "OK"; } else { m.code = 9; m.msg = "Database Error"; } if (int.Parse(member) == 2) { if (createRelation(project_id, member_two, "0")) { m.code = 0; m.msg = "OK"; } else { m.code = 9; m.msg = "Database Error"; } } else if (int.Parse(member) == 3) { if (createRelation(project_id, member_two, "0") && createRelation(project_id, member_three, "0")) { m.code = 0; m.msg = "OK"; } else { m.code = 9; m.msg = "Database Error"; } } if(createRelation(project_id, project_adviser, "1")) { m.code = 0; m.msg = "OK"; } else { m.code = 9; m.msg = "Database Error"; } if (project_co_adviser != "") { if (createRelation(project_id, project_co_adviser, "2")) { m.code = 0; m.msg = "OK"; } else { m.code = 9; m.msg = "Database Error"; } } else { m.code = 11; m.msg = "Parameter Wrong"; } if (createRelation(project_id, project_committee, "3")) { m.code = 0; m.msg = "OK"; } else { m.code = 9; m.msg = "Database Error"; } string status = ""; if (send_approve != null) { if (!send_approve) { status = "1"; } else { status = "2"; } m.code = 0; m.msg = "OK"; } else { m.code = 11; m.msg = "Parameter Wrong"; } dynamic update = JsonConvert.DeserializeObject(updateState(project_id, "1", status)); dynamic decode_update = JsonConvert.DeserializeObject<ResponseMsg>(update); m.code = decode_update.code; m.msg = decode_update.msg; m.value = decode_update.value; } else { m.code = 12; m.msg = "Database Error"; } } catch { m.code = 12; m.msg = "Can't to save form to system"; } return JsonConvert.SerializeObject(m); }
public string updateState(string project_temp ,string state, string status) { project_id = project_temp; ResponseMsg m = new ResponseMsg(); try { string constr = WebConfigurationManager.ConnectionStrings["Dbconnection"].ConnectionString; SqlConnection con = new SqlConnection(constr); con.Open(); string changeState = ""; changeState = "UPDATE project SET Status_ID='" + status + "', State='" + state + "' "; changeState += "WHERE ProjID ='" + project_temp + "'"; SqlCommand cmdUpdate = new SqlCommand(changeState, con); cmdUpdate.ExecuteNonQuery(); m.code = 0; m.msg = "OK"; m.value = ""; } catch { m.code = 9; m.msg = "Database Error"; m.value = ""; } return JsonConvert.SerializeObject(m); }
//complete private bool saveProject(string project_name_th, string project_name_en, string scope, string member) { ResponseMsg m = new ResponseMsg(); try { string constr = WebConfigurationManager.ConnectionStrings["Dbconnection"].ConnectionString; SqlConnection con = new SqlConnection(constr); con.Open(); project_id = createProjectID(); string sqlSave = ""; sqlSave = "INSERT INTO project "; sqlSave += "VALUES ('" + project_id + "','" + project_name_th + "','" + project_name_en + "','" + member + "','" + scope + "', GETDATE() ,'0','0')"; SqlCommand cmdSave = new SqlCommand(sqlSave, con); cmdSave.ExecuteNonQuery(); con.Close(); return true; } catch { return false; } }
public string send_form_two(bool fac, string project, string userID, string date, string topic, string progress, string remark) { string constr = WebConfigurationManager.ConnectionStrings["Dbconnection"].ConnectionString; SqlConnection con = new SqlConnection(constr); con.Open(); string sqlProgress = ""; sqlProgress = "SET IDENTITY_INSERT ProjectOperations ON "; sqlProgress += "INSERT INTO ProjectOperations (ProjOperatID,ProjID,Date,Subject,Progress,Note,ApproveDate) "; sqlProgress += "VALUES ( '" + getID("ProjOperatID", "ProjectOperations") + "','" + project + "','" + date + "','" + topic + "','" + progress + "','" + remark + "',' ')"; SqlCommand cmdProgress = new SqlCommand(sqlProgress, con); cmdProgress.ExecuteNonQuery(); ResponseMsg m = new ResponseMsg(); if (fac) { updateState(project, "2", "2"); if (requestAdviser(project, userID)) { m.code = 0; m.msg = "OK"; m.value = "Send Success"; } } else { updateState(project, "2", "1"); m.code = 0; m.msg = "OK"; m.value = "Save Success"; } return JsonConvert.SerializeObject(m); }