private void GetListPackageDaXuat() { if (maXuatKho != "") { ApiResponse res = new ApiResponse(); res.Status = false; //Load danh sach package try { string url = "getPackageXuatKho"; if (this._checkOther == 1) { url = "getPackageXuatKhoOther"; } var paras = new { ma_xuat_kho = maXuatKho }; res = HTTP.Post(url, paras); } catch (Exception ex) { MessageBox.Show("Loi tai du lieu xuat kho", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } if (res.Status && Util.IsJson(res.RawText)) { try { _listExport = JsonConvert.DeserializeObject <List <PackageInfo> >(res.RawText, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); foreach (PackageInfo item in _listExport) { item.status = "DaXuat"; } } catch (Exception ex) { MessageBox.Show("Khong lay duoc package da xuat"); } } else { if (Util.CleanStr(res.RawText) != "") { MessageBox.Show(Util.CleanStr(res.RawText)); } } } }
private void btnLoad_Click(object sender, EventArgs e) { string maXuatKho = txtMaXuatKho.Text.TrimStart().TrimEnd(); _exp_code = txtMaXuatKho.Text; btnLoad.Enabled = false; btnReset.Enabled = false; listScanned.Clear(); dtListCuon.Rows.Clear(); if (maXuatKho != "") { ApiResponse res = new ApiResponse(); res.Status = false; //Load danh sach linh kien try { //string url = "getListThungXuatKho"; string url = "getListCuonXuatKho"; var paras = new { ma_xuat_kho = maXuatKho }; res = HTTP.Post(url, paras); } catch (Exception ex) { MessageBox.Show("Loi tai du lieu xuat kho", "Loi mang", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } if (res.Status && Util.IsJson(res.RawText)) { try { List <CuonModel> listCuon = JsonConvert.DeserializeObject <List <CuonModel> >(res.RawText, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); btnReset.Enabled = true; //lblChuaQuet.Text = chuaQuet.ToString(); dtListCuon = Util.ToDataTable <CuonModel>(listCuon); dtListCuon.Columns.Add(COL_STATUS); dtListCuon.Columns.Add(COL_ACTION); foreach (DataRow row in dtListCuon.Rows) { if (row["Scanned"].ToString() == "1") { row[COL_STATUS] = "DX"; } else { row[COL_STATUS] = ""; } row[COL_ACTION] = ""; } dgCuonList.DataSource = dtListCuon; dgCuonList.TableStyles.Clear(); DataGridTableStyle tableStyle = new DataGridTableStyle(); tableStyle.MappingName = dtListCuon.TableName; foreach (DataColumn item in dtListCuon.Columns) { DataGridTextBoxColumn tbcName = new DataGridTextBoxColumn(); switch (item.ColumnName) { case "vnpt_pn": { tbcName.MappingName = item.ColumnName; tbcName.HeaderText = "VNPT P/N"; tbcName.Width = 100; } break; case "Code": { tbcName.MappingName = item.ColumnName; tbcName.HeaderText = "Id Cuon"; tbcName.Width = 65; } break; case "Quantity": { tbcName.Width = -1; } break; case "Thung": { tbcName.Width = 65; } break; case "Scanned": { tbcName.Width = -1; } break; case "ThungType": { tbcName.Width = -1; } break; case COL_STATUS: { tbcName.MappingName = item.ColumnName; tbcName.HeaderText = "Trang thai"; tbcName.Width = 30; } break; case COL_ACTION: { tbcName.MappingName = item.ColumnName; tbcName.HeaderText = "Huy"; tbcName.Width = 25; } break; default: { tbcName.Width = 65; } break; } if (tbcName.MappingName != "") { tbcName.MappingName = item.ColumnName; tbcName.HeaderText = item.ColumnName; } tableStyle.GridColumnStyles.Add(tbcName); dangQuet = true; } dgCuonList.TableStyles.Add(tableStyle); dgCuonList.Refresh(); ScanInfo(); } catch (Exception ex) { //btnLoad.Enabled = true; MessageBox.Show("Khong lay duoc du lieu"); txtMaXuatKho.Text = DEFAULT_TXT_MAXK; _exp_code = ""; } } else { //btnLoad.Enabled = true; if (Util.CleanStr(res.RawText) != "") { MessageBox.Show(Util.CleanStr(res.RawText)); } txtMaXuatKho.Text = DEFAULT_TXT_MAXK; _exp_code = ""; } } else { txtMaXuatKho.Focus(); } }