public publicKH getKH(string makh) { string url = @"https://www.phanmemsgd.com/api/publicKHs/" + makh; string sContentType = "application/json"; string ob = JsonConvert.SerializeObject(url); HttpContent s = new StringContent(ob, Encoding.UTF8, sContentType); HttpClient oHttpClient = new HttpClient(); try { var oTaskPostAsync = oHttpClient.GetAsync(url); if (oTaskPostAsync.Result.StatusCode == HttpStatusCode.BadRequest) { return(null); } else if (oTaskPostAsync.Result.StatusCode == HttpStatusCode.OK) { string s1 = oTaskPostAsync.Result.Content.ReadAsStringAsync().ConfigureAwait(true).GetAwaiter().GetResult(); publicKH kh = JsonConvert.DeserializeObject <publicKH>(s1); if (kh != null) { return(kh); } } else { return(null); } } catch (Exception ex) { return(null); } return(null); }
void CusData_ColumnChanged(object sender, System.Data.DataColumnChangeEventArgs e) { //Kiem tra theo ten truong switch (e.Column.ColumnName.ToLower()) { case "mant": MantChanged(e); break; case "dalayhd": // DalayHDChange(e); break; case "hanhtrinh": // DalayHDChange(e); break; } switch (e.Column.Table.TableName.ToLower()) { case "dmkh": if (e.Column.ColumnName.ToLower() == "makh" && _data.DrCurrentMaster != null && _data.DrCurrentMaster.RowState == DataRowState.Added) { if (_data.DrCurrentMaster["MaKH"].ToString().Trim().Length == 10 || _data.DrCurrentMaster["MaKH"].ToString().Trim().Length == 13 || _data.DrCurrentMaster["MaKH"].ToString().Trim().Length == 14) { publicKH kh = getKH(_data.DrCurrentMaster["MaKH"].ToString().Trim()); if (kh != null) { _data.DrCurrentMaster["TenKH"] = kh.TenCty; _data.DrCurrentMaster["Diachi"] = kh.Diachi; _data.DrCurrentMaster["MST"] = kh.MST; _data.DrCurrentMaster.EndEdit(); } } } if (e.Column.ColumnName.ToLower() == "mst" && _data.DrCurrentMaster != null) { if (e.Row["MST"] != DBNull.Value && !isMST(e.Row["MST"].ToString())) { e.Row.SetColumnError("MST", "Mã số thuế không đúnng"); } } break; case "mt35": //Khải Hoàng if (_data.DrCurrentMaster != null && e.Column.ColumnName.ToLower() == "layhd") { AplaiGia(); } break; case "mt38": //Khải Hoàng if (e.Column.ColumnName.ToLower() == "maxe") { UpdateDT38(e); } if (e.Column.ColumnName.ToLower() == "chondon") { List <DataRow> ldr = _data.LstDrCurrentDetails.FindAll(x => x.RowState == DataRowState.Added); if (bool.Parse(e.Row["ChonDon"].ToString()) && ldr.Count == 0) { InsertAll_Donhang(e); } } break; case "mt29": //Piriou if (e.Column.ColumnName.ToLower() == "po_no") { Updatedt29PoNo(e); } if (e.Column.ColumnName.ToLower() == "etadate") { Updatedt29ETA(e); } if (e.Column.ColumnName.ToLower() == "puric") { Updatedt29PurIC(e); } break; case "mt2a": //Piriou if (e.Column.ColumnName.ToLower() == "ngaycan") { Updatedt2ANgayCan(e); } break; //case "mt28"://Piriou // if (e.Column.ColumnName.ToLower() == "ngayct" && e.Row.RowState==DataRowState.Added) // { // e.Row["NgayCT"] =DateTime.Parse(Config.GetValue("NgayHethong").ToString()); // e.Row.EndEdit(); // } // if (e.Column.ColumnName.ToLower() == "revbom" && e.Row.RowState == DataRowState.Added) // { // e.Row["RevBOM"] ="0"; // e.Row.EndEdit(); // } // break; } //ValidMtID(e); }