private void SaveInfo() { try { InfoIPC ipc = new InfoIPC(); ipc.TenCongTy = txtTenCty.Text; ipc.NguoiGui = txtNguoiGui.Text; ipc.Mobile = txtMobile.Text; ipc.Email = txtEmail.Text; ipc.DiaChi = txtDiaChi.Text; var jsonsave = new JavaScriptSerializer().Serialize(ipc); string base64info = Convert.ToBase64String(Encoding.UTF8.GetBytes(jsonsave.ToString())); string str = "[" + string.Format(@"{{""Key"":""Key"",""value"":""{0}"",""Type"":""string""}},{{""Key"":""Value"",""value"":""{1}"",""Type"":""string""}},{{""Key"":""UserID"",""value"":""{2}"",""Type"":""string""}}", "Info", base64info, Form_Main.user.Username) + "]"; var json = new JavaScriptSerializer().Serialize(new { StoreProcedure = "sp_UpdateInfoMaster", Param = str }); string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_SaveQuote"; json = API.API_POS(sLink, json); dynamic jsondata = JObject.Parse(json); var jsondataChild = jsondata.GetValue("Data"); var Result = jsondataChild.First.GetValue("Result").Value; var Message = jsondataChild.First.GetValue("Message").Value; XtraMessageBox.Show(Message, "Thông Báo", System.Windows.Forms.MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_MasterData", "SaveInfo()", ex.ToString())); XtraMessageBox.Show("Cập Nhật Thông Tin Không Thành Công", "Thông Báo", System.Windows.Forms.MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void SaveInfo() { try { InfoIPC ipc = new InfoIPC(); ipc.TenCongTy = txtTenCty.Text; ipc.NguoiGui = txtNguoiGui.Text; ipc.Mobile = txtMobile.Text; ipc.Email = txtEmail.Text; ipc.DiaChi = txtDiaChi.Text; var jsonsave = new JavaScriptSerializer().Serialize(ipc); string base64info = Convert.ToBase64String(Encoding.UTF8.GetBytes(jsonsave.ToString())); //string str = "[" + string.Format(@"{{""Key"":""Key"",""value"":""{0}"",""Type"":""string""}},{{""Key"":""Value"",""value"":""{1}"",""Type"":""string""}},{{""Key"":""UserID"",""value"":""{2}"",""Type"":""string""}}", "Info", base64info, Form_Main.user.Username) + "]"; //var json = new JavaScriptSerializer().Serialize(new { StoreProcedure = "sp_UpdateInfoMaster", Param = str }); //string sLink = Form_Main.URL_API+ "/api/IPC247/sp_extension_SaveQuote"; //json = API.API_POS(sLink, json); //dynamic jsondata = JObject.Parse(json); //var jsondataChild = jsondata.GetValue("Data"); //var Result = jsondataChild.First.GetValue("Result").Value; //var Message = jsondataChild.First.GetValue("Message").Value; Dictionary <string, object> param = new Dictionary <string, object>(); param.Add("Key", "Info"); //0 param.Add("Value", base64info); //1 param.Add("UserID", Form_Main.user.Username); //2 DataTable dt = SQLHelper.ExecuteDataTableUndefine("sp_UpdateInfoMaster", param); if (dt != null && dt.Rows.Count > 0) { var Result = dt.Rows[0]["Result"].ToString(); var Message = dt.Rows[0]["Message"].ToString(); XtraMessageBox.Show(Message, "Thông Báo", System.Windows.Forms.MessageBoxButtons.OK, MessageBoxIcon.Information); } else { API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_MasterData", "SaveInfo()", "Không lấy được thông tin")); } } catch (Exception ex) { API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_MasterData", "SaveInfo()", ex.ToString())); XtraMessageBox.Show("Cập Nhật Thông Tin Không Thành Công", "Thông Báo", System.Windows.Forms.MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void LoadThongTinDefault() { try { string sql_Exect = "Exec sp_GetInfoMaster @Key='Info,ImageLeft,ImageRight'"; //11 string sLink = URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect; var json = API.API_GET(sLink); var jsondata = JObject.Parse(json).GetValue("Data"); DataTable dt = (DataTable)JsonConvert.DeserializeObject(jsondata.ToString(), (typeof(DataTable))); string base64 = dt.Rows[0][0].ToString(); json = System.Text.Encoding.UTF8.GetString(System.Convert.FromBase64String(base64)); JObject a = JObject.Parse(json); info = new InfoIPC(); info.TenCongTy = a.GetValue("TenCongTy").ToString(); info.NguoiGui = a.GetValue("NguoiGui").ToString(); info.Mobile = a.GetValue("Mobile").ToString(); info.Email = a.GetValue("Email").ToString(); info.DiaChi = a.GetValue("DiaChi").ToString(); string FileFolder = AppDomain.CurrentDomain.BaseDirectory + "/AppData/Image"; if (!Directory.Exists(FileFolder)) { Directory.CreateDirectory(FileFolder); } Image img; string image = dt.Rows[1][0].ToString(); if (image != "") { FileFolder = FileFolder + "/" + "ImageLeft.jpg"; if (File.Exists(FileFolder)) { File.Delete(FileFolder); } try { img = byteArrayToImage(Convert.FromBase64String(image)); img.Save(FileFolder); } catch (Exception ex) { API.API_ERRORLOG(new ERRORLOG(IPAddress, "Form_Main", "LoadThongTinDefault() - Save ImageLeft.jpg", ex.ToString())); } } image = dt.Rows[2][0].ToString(); if (image != "") { FileFolder = AppDomain.CurrentDomain.BaseDirectory + "/AppData/Image"; FileFolder = FileFolder + "/" + "ImageRight.jpg"; if (!File.Exists(FileFolder)) { File.Delete(FileFolder); } try { img = byteArrayToImage(Convert.FromBase64String(image)); img.Save(FileFolder); } catch (Exception ex) { API.API_ERRORLOG(new ERRORLOG(IPAddress, "Form_Main", "LoadThongTinDefault() - Save ImageRight.jpg", ex.ToString())); } } } catch (Exception ex) { API.API_ERRORLOG(new ERRORLOG(IPAddress, "Form_Main", "LoadThongTinDefault()", ex.ToString())); } }