protected void m_grid_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { int id = e.RowIndex; m_grid.EditIndex = id; GridViewRow row = m_grid.Rows[id]; string ThietBi_id = ""; string ThanhPham_id = ""; string ThietBi = ((TextBox)row.FindControl("txtUTenThietBi")).Text; string ThanhPham = ((TextBox)row.FindControl("txtUTenThanhPham")).Text; Int32 SoLuong = Convert.ToInt32(((TextBox)row.FindControl("txtUSoLuong")).Text); DataTable tblTemp = new DataTable(); clsThanhPham oThanhPham = new clsThanhPham(); clsThietBi oThietBi = new clsThietBi(); if (ThietBi != "") { tblTemp = oThietBi.Select(); int i; for (i = 0; i < tblTemp.Rows.Count; i++) { if (tblTemp.Rows[i]["TenThietBi"].ToString().Trim() == ThietBi.Trim()) { ThietBi_id = tblTemp.Rows[i]["ThietBi_Id"].ToString(); } } } if (ThanhPham != "") { tblTemp = oThanhPham.Select(); int i; for (i = 0; i < tblTemp.Rows.Count; i++) { if (tblTemp.Rows[i]["TenThanhPham"].ToString().Trim() == ThanhPham.Trim()) { ThanhPham_id = tblTemp.Rows[i]["ThanhPham_Id"].ToString(); } } } if (m_grid.DataKeys[id].Value.ToString() != "") { clsKeHoachNhapXuat objKeHoachNhapXuat = new clsKeHoachNhapXuat(); objKeHoachNhapXuat.KeHoachNhapXuat_Id = sKey; objKeHoachNhapXuat.ThietBi_Id = ThietBi_id; objKeHoachNhapXuat.ThanhPham_Id = ThanhPham_id; objKeHoachNhapXuat.So_Luong = SoLuong; int _result = objKeHoachNhapXuat.UpdateChiTiet(); if (_result == 1) { ltlAnnouncement.Text = "Sửa kế hoạch nhập xuất chi tiết '" + m_grid.DataKeys[e.RowIndex].Value.ToString() + "' thành công!"; } if (_result < 0) { ltlAnnouncement.Text = "Có lỗi trong quá trình sửa dữ liệu!"; } } } catch (Exception ex) { ltlAnnouncement.Text = "Khong cap nhat duoc du lieu. Vui long lien he voi quan tri<br>" + ex.Message; } bindData(-1); }
protected void m_grid_RowCommand(object sender, GridViewCommandEventArgs e) { try { string commandName = e.CommandName; GridViewRow row = m_grid.FooterRow; if (commandName == "Insert") { clsKeHoachNhapXuat objKeHoachNhapXuat = new clsKeHoachNhapXuat(); string ThietBi_id = ((DropDownList)row.FindControl("txtITenThietBi")).Text; string ThanhPham_id = ((DropDownList)row.FindControl("txtITenThanhPham")).Text; int LoaiNhap_id = Convert.ToInt32(((DropDownList)row.FindControl("txtITenLoaiNhap")).Text); Int32 SoLuong = Convert.ToInt32(((TextBox)row.FindControl("txtISoLuong")).Text); objKeHoachNhapXuat.KeHoachNhapXuat_Id = sKey; if (LoaiNhap_id == 1) //nhập thành phẩm { //objKeHoachNhapXuat.ThietBi_Id = DBNull.Value; objKeHoachNhapXuat.ThanhPham_Id = ThanhPham_id; } else if (LoaiNhap_id == 2) //nhập thiết bị { objKeHoachNhapXuat.ThietBi_Id = ThietBi_id; //objKeHoachNhapXuat.ThanhPham_Id = ThanhPham_id; } objKeHoachNhapXuat.So_Luong = SoLuong; int _result = objKeHoachNhapXuat.InsertChiTiet(); if (_result >= 1) { ltlAnnouncement.Text = "Thêm mới kho '" + ThietBi_id + "' thành công!"; } if (_result == -1) { ltlAnnouncement.Text = "Kho '" + ThietBi_id + "' đã tồn tại, bạn nên kiểm tra lại!"; } if (_result == 0) { ltlAnnouncement.Text = "Có lỗi trong quá trình thêm mới!"; } bindData(-1); } } catch (Exception ex) { ltlAnnouncement.Text = "Khong them moi duoc du lieu. Vui long lien he voi quan tri<br>" + ex.Message; } }
protected void m_grid_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { int id = e.RowIndex; m_grid.EditIndex = id; Guid delId = new Guid(m_grid.DataKeys[e.RowIndex].Value.ToString()); if (m_grid.DataKeys[e.RowIndex].Value.ToString() != "") { clsKeHoachNhapXuat objKeHoachNhapXuat = new clsKeHoachNhapXuat(); objKeHoachNhapXuat.KeHoachNhapXuatChiTiet_Id = m_grid.DataKeys[e.RowIndex].Value.ToString(); int status_Delete = objKeHoachNhapXuat.DeleteChiTiet(); if (status_Delete == 1) { ltlAnnouncement.Text = "Xóa thành công kế hoạch nhập xuất chi tiết!"; } if (status_Delete <= 0) { ltlAnnouncement.Text = "Không xóa được kế hoạch nhập xuất chi tiết."; } } } catch (Exception ex) { ltlAnnouncement.Text = "Lỗi trong quá trình xóa kế hoạch nhập xuất chi tiết: " + ex.ToString(); } bindData(-1); }
private void bindData(int index) { try { //LAY DANH SACH CAC QUOC GIA RA dsGroup = new DataTable(); dsTongHop = new DataTable(); clsKeHoachNhapXuat objKeHoachNhapXuatChiTiet = new clsKeHoachNhapXuat(); objKeHoachNhapXuatChiTiet.KeHoachNhapXuat_Id = sKey; dsGroup = objKeHoachNhapXuatChiTiet.SelectChiTiet(); dsTongHop = objKeHoachNhapXuatChiTiet.Select_onerow(); objKeHoachNhapXuatChiTiet.KeHoachNhapXuatChiTiet_Id = "0"; //Hiển thị tổng hợp if (dsTongHop.Rows.Count > 0) { if (dsTongHop.Rows[0]["KieuNhapXuat"] == "1") { txtNhapXuat.Text = "Phiếu nhập"; } else { txtNhapXuat.Text = "Phiếu xuất"; } txtKho.Text = dsTongHop.Rows[0]["TenKho"].ToString(); //dtpNgayLap.DateInput. = dsTongHop.Rows[0]["NgayLap"].ToString(); txtNguoiLap.Text = dsTongHop.Rows[0]["NguoiLap"].ToString(); txtLyDoNhap.Text = dsTongHop.Rows[0]["LyDoNhapXuat"].ToString(); txtDienGiai.Text = dsTongHop.Rows[0]["Dien_Giai"].ToString(); if (dsTongHop.Rows[0]["DoiTac_Id"] != DBNull.Value) { txtNoiNhan.Text = "Đối tác"; txtGiaTriNoiNhan.Text = dsTongHop.Rows[0]["TenDoiTac"].ToString(); } else if (dsTongHop.Rows[0]["NhaCungCap_Id"] != DBNull.Value) { txtNoiNhan.Text = "Nhà cung cấp"; txtGiaTriNoiNhan.Text = dsTongHop.Rows[0]["TenNCC"].ToString(); } else if (dsTongHop.Rows[0]["NhanVien_Nhan_Id"] != DBNull.Value) { txtNoiNhan.Text = "Nhân viên"; txtGiaTriNoiNhan.Text = dsTongHop.Rows[0]["TenDayDu"].ToString(); } dtpNgayLap.SelectedDate = Convert.ToDateTime(dsTongHop.Rows[0]["NgayLap"]); } m_grid.EditIndex = index; m_grid.DataSource = dsGroup; bool add = false; if (dsGroup.Rows.Count <= 0) { dsGroup.Rows.Add(dsGroup.NewRow()); add = true; } // m_grid.DataBind(); if (add) m_grid.Rows[0].Visible = false; if (m_grid.Rows.Count > 0) { string confirm = "return confirm('Bạn thật sự muốn xóa row này?')"; for (int i = 0; i < m_grid.Rows.Count; i++) { GridViewRow row = m_grid.Rows[i]; LinkButton lbutton1 = (LinkButton)row.FindControl("cmdDelete"); if (lbutton1 != null) { lbutton1.Visible = D_Option; lbutton1.Attributes.Add("onclick", confirm); //lbutton1.Enabled = D_Option; } LinkButton lbutton2 = (LinkButton)row.FindControl("cmdEdit"); if (lbutton2 != null) lbutton2.Visible = U_Option; } } //XET QUYETN CHO CHUC NANG INSERT GridViewRow row1 = m_grid.FooterRow; if (row1 != null) { row1.Visible = I_Option; } } catch (Exception ex) { } }
protected void btnGhi_Click(object sender, System.EventArgs e) { clsKeHoachNhapXuat oKeHoachNhapXuat = new clsKeHoachNhapXuat(); oKeHoachNhapXuat.KeHoachNhapXuat_Id = sKey; oKeHoachNhapXuat.Code = sCode; oKeHoachNhapXuat.NhanVien_PheDuyet_Id = "83e36d21-8607-4b6f-8dcc-4be0c0fd4ba5"; oKeHoachNhapXuat.Dien_Giai = sDienGiai; oKeHoachNhapXuat.PheDuyetKeHoach(); Init(); BindData(); }
private void bindData(int index) { try { //LAY DANH SACH CAC QUOC GIA RA dsGroup = new DataTable(); clsKeHoachNhapXuat objKeHoachNhapXuatChiTiet = new clsKeHoachNhapXuat(); objKeHoachNhapXuatChiTiet.KeHoachNhapXuat_Id = sKeHoachNhapXuat_Id; dsGroup = objKeHoachNhapXuatChiTiet.SelectChiTiet(); objKeHoachNhapXuatChiTiet.KeHoachNhapXuatChiTiet_Id = "0"; m_grid.EditIndex = index; m_grid.DataSource = dsGroup; bool add = false; if (dsGroup.Rows.Count <= 0) { dsGroup.Rows.Add(dsGroup.NewRow()); add = true; } // m_grid.DataBind(); if (add) m_grid.Rows[0].Visible = false; if (m_grid.Rows.Count > 0) { string confirm = "return confirm('Bạn thật sự muốn xóa row này?')"; for (int i = 0; i < m_grid.Rows.Count; i++) { GridViewRow row = m_grid.Rows[i]; LinkButton lbutton1 = (LinkButton)row.FindControl("cmdDelete"); if (lbutton1 != null) { lbutton1.Visible = D_Option; lbutton1.Attributes.Add("onclick", confirm); //lbutton1.Enabled = D_Option; } LinkButton lbutton2 = (LinkButton)row.FindControl("cmdEdit"); if (lbutton2 != null) lbutton2.Visible = U_Option; } } //XET QUYETN CHO CHUC NANG INSERT GridViewRow row1 = m_grid.FooterRow; if (row1 != null) { row1.Visible = I_Option; } GridViewRow row10 = m_grid.FooterRow; string LoaiNhap_id = ((DropDownList)row10.FindControl("txtITenLoaiNhap")).Text; DropDownList cboThanhPham = (DropDownList)row10.FindControl("txtITenThanhPham"); cboThanhPham.DataSource = GetSourceTenThanhPham(LoaiNhap_id); cboThanhPham.DataTextField = "TenHangMuc"; cboThanhPham.DataValueField = "HangMuc_Id"; cboThanhPham.DataBind(); } catch (Exception ex) { } }
protected void m_grid_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { clsKeHoachNhapXuat objKeHoachNhapXuat = new clsKeHoachNhapXuat(); int id = e.RowIndex; m_grid.EditIndex = id; GridViewRow row = m_grid.Rows[id]; //sKeHoachNhapXuat_Id = Guid.NewGuid().ToString(); objKeHoachNhapXuat.KeHoachNhapXuatChiTiet_Id = m_grid.DataKeys[e.RowIndex].Value.ToString(); DataTable tbltem = new DataTable(); tbltem = objKeHoachNhapXuat.SelectChiTiet_onerow(); int LoaiNhap_id = Convert.ToInt32(((DropDownList)row.FindControl("txtUTenLoaiNhap")).Text); string ThanhPham_id = ""; Int32 SoLuong = Convert.ToInt32(((TextBox)row.FindControl("txtUSoLuong")).Text); string ThietBi_id = ""; // short updateId = Int16.Parse(m_grid.DataKeys[id].Value.ToString()); if (m_grid.DataKeys[id].Value.ToString() != "") { if (tbltem.Rows.Count > 0) { if (tbltem.Rows[0]["ThietBi_Id"] == DBNull.Value) { ThanhPham_id = tbltem.Rows[0]["ThanhPham_Id"].ToString(); ThietBi_id = ""; } else { ThietBi_id = tbltem.Rows[0]["ThietBi_Id"].ToString(); ThanhPham_id = ""; } } objKeHoachNhapXuat.KeHoachNhapXuat_Id = sKey; objKeHoachNhapXuat.ThanhPham_Id = ThanhPham_id; objKeHoachNhapXuat.ThietBi_Id = ThietBi_id; objKeHoachNhapXuat.So_Luong = SoLuong; int _result = objKeHoachNhapXuat.InsertChiTiet(); if (_result == 1) { ltlAnnouncement.Text = "Sửa kế hoạch nhập xuất chi tiết '" + sKey + "' thành công!"; } if (_result < 0) { ltlAnnouncement.Text = "Có lỗi trong quá trình sửa dữ liệu!"; } } } catch (Exception ex) { ltlAnnouncement.Text = "Khong cap nhat duoc du lieu. Vui long lien he voi quan tri<br>" + ex.Message; } bindData(-1); }
protected void btnGhi_Click(object sender, System.EventArgs e) { if (bsua==0) //thêm mới { clsKeHoachNhapXuat oKeHoachNhapXuat = new clsKeHoachNhapXuat(); oKeHoachNhapXuat.KeHoachNhapXuat_Id = sKeHoachNhapXuat_Id; oKeHoachNhapXuat.Kho_Id = cboKho.SelectedValue; oKeHoachNhapXuat.Code = Guid.NewGuid().ToString(); oKeHoachNhapXuat.NhanVien_Lap_Id = cboNguoiLap.SelectedValue; oKeHoachNhapXuat.LyDoNhap = txtLyDoNhap.Text; oKeHoachNhapXuat.Dien_Giai = txtDienGiai.Text; oKeHoachNhapXuat.KieuNhapXuat = Convert.ToInt16(cboNhapXuat.SelectedValue); oKeHoachNhapXuat.DoiTac_Id = DBNull.Value.ToString(); oKeHoachNhapXuat.NhaCungCap_Id = DBNull.Value.ToString(); oKeHoachNhapXuat.NhanVien_Nhan_Id = DBNull.Value.ToString(); if (cboNoiNhan.SelectedIndex == 0) { oKeHoachNhapXuat.NhanVien_Nhan_Id = cboGiaTriNoiNhan.SelectedValue; } else if (cboNoiNhan.SelectedIndex == 1) { oKeHoachNhapXuat.DoiTac_Id = cboGiaTriNoiNhan.SelectedValue; } else { oKeHoachNhapXuat.NhaCungCap_Id = cboGiaTriNoiNhan.SelectedValue; } oKeHoachNhapXuat.Insert(); } else //sửa { clsKeHoachNhapXuat oKeHoachNhapXuat = new clsKeHoachNhapXuat(); oKeHoachNhapXuat.NhanVien_Lap_Id = cboNguoiLap.SelectedValue; oKeHoachNhapXuat.KeHoachNhapXuat_Id = Guid.NewGuid().ToString(); oKeHoachNhapXuat.Kho_Id = cboKho.SelectedValue; oKeHoachNhapXuat.Code = Guid.NewGuid().ToString(); oKeHoachNhapXuat.LyDoNhap = txtLyDoNhap.Text; oKeHoachNhapXuat.Dien_Giai = txtDienGiai.Text; oKeHoachNhapXuat.TinhTrang = "DE_NGHI"; oKeHoachNhapXuat.DoiTac_Id = DBNull.Value.ToString(); oKeHoachNhapXuat.NhaCungCap_Id = DBNull.Value.ToString(); oKeHoachNhapXuat.NhanVien_Nhan_Id = DBNull.Value.ToString(); if (cboNoiNhan.SelectedIndex == 0) { oKeHoachNhapXuat.NhanVien_Nhan_Id = cboGiaTriNoiNhan.SelectedValue; } else if (cboNoiNhan.SelectedIndex == 1) { oKeHoachNhapXuat.DoiTac_Id = cboGiaTriNoiNhan.SelectedValue; } else { oKeHoachNhapXuat.NhaCungCap_Id = cboGiaTriNoiNhan.SelectedValue; } oKeHoachNhapXuat.Update(); sKey = ""; bsua = 0; } Init(); BindData("DE_NGHI"); bindData(-1); }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.ToString() == "Sửa") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow gvRow = GridView1.Rows[index]; if (GridView1.DataKeys[index].Value.ToString() != "") { clsKeHoachNhapXuat objKeHoachNhapXuat = new clsKeHoachNhapXuat(); objKeHoachNhapXuat.KeHoachNhapXuat_Id = GridView1.DataKeys[index].Value.ToString(); sKeHoachNhapXuat_Id = GridView1.DataKeys[index].Value.ToString(); sKey = GridView1.DataKeys[index].Value.ToString(); DataTable mytable = new DataTable(); mytable = objKeHoachNhapXuat.Select_onerow(); if (mytable.Rows.Count > 0) { cboKho.SelectedValue = mytable.Rows[0]["Kho_Id"].ToString(); cboNguoiLap.SelectedValue = mytable.Rows[0]["NhanVien_Lap_Id"].ToString(); txtLyDoNhap.Text = mytable.Rows[0]["LyDoNhapXuat"].ToString(); txtDienGiai.Text = mytable.Rows[0]["Dien_Giai"].ToString(); //cboDoiTac.SelectedValue = mytable.Rows[0]["DoiTac_Id"].ToString(); //cboNhaCungCap.SelectedValue = mytable.Rows[0]["NhaCungCap_Id"].ToString(); dtpNgayLap.SelectedDate = Convert.ToDateTime(mytable.Rows[0]["NgayLap"]); //sửa hết if (mytable.Rows[0]["TinhTrang"].ToString() == "DE_NGHI") { bsua = 1; } //chỉ sửa tình trạng else if (mytable.Rows[0]["TinhTrang"].ToString() == "PHE_DUYET" || mytable.Rows[0]["TinhTrang"].ToString() == "KHONG_PHE_DUYET") { bsua = 2; txtLyDoNhap.Enabled = false; txtDienGiai.Enabled = false; cboKho.Enabled = false; dtpNgayLap.Enabled = false; cboNguoiLap.Enabled = false; } else //không sửa { bsua = 3; txtLyDoNhap.Enabled = false; txtDienGiai.Enabled = false; cboKho.Enabled = false; dtpNgayLap.Enabled = false; cboNguoiLap.Enabled = false; btnGhi.Enabled = false; } } } } else if (e.CommandName.ToString() == "Xóa") { try { int id = Convert.ToInt32(e.CommandArgument); GridView1.EditIndex = id; Guid delId = new Guid(GridView1.DataKeys[id].Value.ToString()); if (GridView1.DataKeys[id].Value.ToString() != "") { clsKeHoachNhapXuat objKeHoachNhapXuat = new clsKeHoachNhapXuat(); objKeHoachNhapXuat.KeHoachNhapXuat_Id = GridView1.DataKeys[id].Value.ToString(); DataTable mytable = new DataTable(); mytable = objKeHoachNhapXuat.Select_onerow(); objKeHoachNhapXuat.NhanVien_Lap_Id = mytable.Rows[0]["NhanVien_Lap_Id"].ToString(); int status_Delete = objKeHoachNhapXuat.Delete(); } } catch (Exception ex) { ltlAnnouncement.Text = "Lỗi trong quá trình xóa nhóm người dùng: " + ex.ToString(); } } BindData("DE_NGHI"); bindData(-1); }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.ToString() == "PheDuyet") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow gvRow = GridView1.Rows[index]; if (GridView1.DataKeys[index].Value.ToString() != "") { clsKeHoachNhapXuat objKeHoachNhapXuat = new clsKeHoachNhapXuat(); objKeHoachNhapXuat.KeHoachNhapXuat_Id = GridView1.DataKeys[index].Value.ToString(); sKey = GridView1.DataKeys[index].Value.ToString(); //hien thi popup HttpCookie C = new HttpCookie("KeHoach_ID"); C["Data"] = sKey; Response.Cookies.Add(C); string window = "../QLKho/popPheDuyetKeHoach.aspx"; string newwin = "window.open('" + window + "');"; ClientScript.RegisterStartupScript(this.GetType(), "pop", newwin, true); //txtKeHoachID.Text = sKey; //DataTable mytable = new DataTable(); //mytable = objKeHoachNhapXuat.Select_onerow(); //if (mytable.Rows.Count > 0) //{ // sDienGiai = mytable.Rows[0]["Dien_Giai"].ToString(); // sCode = mytable.Rows[0]["Code"].ToString(); //} //bsua = true; //bindData(-1); } } else if (e.CommandName.ToString() == "KhongPheDuyet") { //try //{ // int id = Convert.ToInt32(e.CommandArgument); // GridView1.EditIndex = id; // Guid delId = new Guid(GridView1.DataKeys[id].Value.ToString()); // if (GridView1.DataKeys[id].Value.ToString() != "") // { // clsKeHoachNhapXuat objKeHoachNhapXuat = new clsKeHoachNhapXuat(); // objKeHoachNhapXuat.KeHoachNhapXuat_Id = GridView1.DataKeys[id].Value.ToString(); // DataTable mytable = new DataTable(); // mytable = objKeHoachNhapXuat.Select_onerow(); // objKeHoachNhapXuat.NhanVien_Lap_Id = mytable.Rows[0]["NhanVien_Lap_Id"].ToString(); // int status_Delete = objKeHoachNhapXuat.Delete(); // } //} //catch (Exception ex) //{ // ltlAnnouncement.Text = "Lỗi trong quá trình xóa nhóm người dùng: " + ex.ToString(); //} } BindData(); }
private void bindData(int index) { try { dsTongHop = new DataTable(); clsKeHoachNhapXuat objKeHoachNhapXuatChiTiet = new clsKeHoachNhapXuat(); clsPhieuNhapChiTiet objPhieuNhapChiTiet= new clsPhieuNhapChiTiet(); objPhieuNhapChiTiet.KeHoachNhapXuat_Id = cboKeHoachNhapXuat.SelectedValue.ToString(); dsGroup = objPhieuNhapChiTiet.Select(); objKeHoachNhapXuatChiTiet.KeHoachNhapXuat_Id = cboKeHoachNhapXuat.SelectedValue.ToString(); dsTongHop = objKeHoachNhapXuatChiTiet.Select_onerow(); // objKeHoachNhapXuatChiTiet.KeHoachNhapXuat_Id = cboKeHoachNhapXuat.SelectedValue.ToString(); dsChiTiet = objKeHoachNhapXuatChiTiet.SelectChiTiet(); m_grid1.EditIndex = index; m_grid1.DataSource = dsChiTiet; m_grid1.DataBind(); objPhieuNhapChiTiet.PhieuNhapChiTiet_Id = "0"; //Hiển thị tổng hợp if (dsTongHop.Rows.Count > 0) { if (dsTongHop.Rows[0]["KieuNhapXuat"] == "1") { txtNhapXuat.Text = "Phiếu nhập"; } else { txtNhapXuat.Text = "Phiếu xuất"; } txtKho.Text = dsTongHop.Rows[0]["TenKho"].ToString(); txtNguoiLap.Text = dsTongHop.Rows[0]["NguoiLap"].ToString(); txtLyDoNhapXuat1.Text = dsTongHop.Rows[0]["LyDoNhapXuat"].ToString(); txtDienGiai1.Text = dsTongHop.Rows[0]["Dien_Giai"].ToString(); if (dsTongHop.Rows[0]["DoiTac_Id"] != DBNull.Value) { txtNoiNhan.Text = "Đối tác"; txtGiaTriNoiNhan.Text = dsTongHop.Rows[0]["TenDoiTac"].ToString(); } else if (dsTongHop.Rows[0]["NhaCungCap_Id"] != DBNull.Value) { txtNoiNhan.Text = "Nhà cung cấp"; txtGiaTriNoiNhan.Text = dsTongHop.Rows[0]["TenNCC"].ToString(); } else if (dsTongHop.Rows[0]["NhanVien_Nhan_Id"] != DBNull.Value) { txtNoiNhan.Text = "Nhân viên"; txtGiaTriNoiNhan.Text = dsTongHop.Rows[0]["TenDayDu"].ToString(); } dtpNgayLap.SelectedDate = Convert.ToDateTime(dsTongHop.Rows[0]["NgayLap"]); } bool add = false; if (dsGroup.Rows.Count <= 0) { dsGroup.Rows.Add(dsGroup.NewRow()); add = true; } } catch (Exception ex) { } }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.ToString() == "SuaChiTiet") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow gvRow = GridView1.Rows[index]; if (GridView1.DataKeys[index].Value.ToString() != "") { clsKeHoachNhapXuat objKeHoachNhapXuat = new clsKeHoachNhapXuat(); objKeHoachNhapXuat.KeHoachNhapXuat_Id = GridView1.DataKeys[index].Value.ToString(); sKey = GridView1.DataKeys[index].Value.ToString(); //hien thi popup HttpCookie C = new HttpCookie("PhieuNhap_Id"); C["Data"] = sKey; Response.Cookies.Add(C); string window = "../QLKho/XacNhanXuatKhoChiTiet.aspx"; string newwin = "window.open('" + window + "');"; ClientScript.RegisterStartupScript(this.GetType(), "pop", newwin, true); } } BindData(); }
private void bindData(int index) { try { clsPhieuXuatChiTiet objPhieuXuatChiTiet = new clsPhieuXuatChiTiet(); clsKeHoachNhapXuat objKeHoachNhapXuatChiTiet = new clsKeHoachNhapXuat(); objPhieuXuatChiTiet.KeHoachNhapXuat_Id = sKey; dsGroup = objPhieuXuatChiTiet.Select(); objKeHoachNhapXuatChiTiet.KeHoachNhapXuat_Id = sKey; dsTongHop = objKeHoachNhapXuatChiTiet.Select_onerow(); objPhieuXuatChiTiet.PhieuXuatChiTiet_Id = "0"; m_grid.EditIndex = index; m_grid.DataSource = dsGroup; bool add = false; if (dsGroup.Rows.Count <= 0) { dsGroup.Rows.Add(dsGroup.NewRow()); add = true; } // m_grid.DataBind(); if (add) m_grid.Rows[0].Visible = false; if (m_grid.Rows.Count > 0) { string confirm = "return confirm('Bạn thật sự muốn xóa row này?')"; for (int i = 0; i < m_grid.Rows.Count; i++) { GridViewRow row = m_grid.Rows[i]; LinkButton lbutton1 = (LinkButton)row.FindControl("cmdDelete"); if (lbutton1 != null) { lbutton1.Visible = D_Option; lbutton1.Attributes.Add("onclick", confirm); //lbutton1.Enabled = D_Option; } LinkButton lbutton2 = (LinkButton)row.FindControl("cmdEdit"); if (lbutton2 != null) lbutton2.Visible = U_Option; } } //XET QUYETN CHO CHUC NANG INSERT GridViewRow row1 = m_grid.FooterRow; if (row1 != null) { row1.Visible = I_Option; } } catch (Exception ex) { } }
protected void btnGhi_Click(object sender, System.EventArgs e) { clsKeHoachNhapXuat oKeHoachNhapXuat = new clsKeHoachNhapXuat(); oKeHoachNhapXuat.KeHoachNhapXuat_Id = sKey; oKeHoachNhapXuat.Code = sCode; oKeHoachNhapXuat.NhanVien_PheDuyet_Id = "83e36d21-8607-4b6f-8dcc-4be0c0fd4ba5"; oKeHoachNhapXuat.Dien_Giai = sDienGiai; oKeHoachNhapXuat.PheDuyetKeHoach(); Init(); bindData(-1); lblCanhBao.Text = "Phê duyệt thành công!"; }