Пример #1
0
        protected void btnCapNhat_Click(object sender, EventArgs e)
        {
            SYS_Session session = (SYS_Session)Session["SYS_Session"];

            if (Session["Add"] + "" == "0")
            {
                CBDN.DM_NhaMay cv   = (CBDN.DM_NhaMay)grdDVT.GetRow(grdDVT.FocusedRowIndex);
                CBDN.DM_NhaMay qtCT = db.DM_NhaMays.SingleOrDefault(x => x.ID == cv.ID);
                if (!CheckName(txtMaPhong.Text, cv.ID))
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Mã nhà máy không được trùng');", true); return;
                }
                if (txtTenPhong.Value + "" == "")
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Tên nhà máy không thể bỏ trống');", true);
                    return;
                }

                //CBDN.DM_NhaMay qtCT = new CBDN.DM_NhaMay();
                qtCT.TenNhaMay = txtTenPhong.Text;
                qtCT.DienThoai = txtSDT.Text;
                qtCT.MoTa      = txtMota.Text;
                qtCT.DiaChi    = txtDiaChi.Text;
                db.SubmitChanges();
            }
            else
            {
                if (txtMaPhong.Text + "" == "")
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Mã nhà máy không được để trống');", true);
                    txtMaPhong.Focus(); return;
                }
                if (txtTenPhong.Text == "")
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Tên nhà máy không được để trống');", true);
                    txtTenPhong.Focus(); return;
                }

                if (!CheckName(txtMaPhong.Text, 0))
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Mã nhà máy không được trùng');", true); return;
                }


                CBDN.DM_NhaMay cv = new CBDN.DM_NhaMay();
                cv.MaNhaMay   = txtMaPhong.Text;
                cv.TenNhaMay  = txtTenPhong.Text;
                cv.IDMADVIQLY = int.Parse(session.User.ma_dviqly + "");
                cv.DiaChi     = txtDiaChi.Text;
                cv.MoTa       = txtMota.Text;
                cv.DienThoai  = txtSDT.Text;
                db.DM_NhaMays.InsertOnSubmit(cv);
                db.SubmitChanges();
            }
            _DataBind();
        }
Пример #2
0
        protected void btnSua_Click(object sender, EventArgs e)
        {
            pcAddRoles.ShowOnPageLoad = true;
            Session["Add"]            = 0;
            SYS_Session session = (SYS_Session)Session["SYS_Session"];

            CBDN.DM_NhaMay cv = (CBDN.DM_NhaMay)grdDVT.GetRow(grdDVT.FocusedRowIndex);
            txtMaPhong.Text  = cv.MaNhaMay;
            txtTenPhong.Text = cv.TenNhaMay;
            txtDiaChi.Text   = cv.DiaChi;
            txtSDT.Text      = cv.DienThoai;
            txtMota.Text     = cv.MoTa;
        }
Пример #3
0
 protected void grdDVT_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
 {
     try
     {
         SYS_Session    session  = (SYS_Session)Session["SYS_Session"];
         CBDN.DM_NhaMay HoatDong = (CBDN.DM_NhaMay)grdDVT.GetRow(grdDVT.FocusedRowIndex);
         CBDN.DM_NhaMay cv       = new CBDN.DM_NhaMay();
         cv = db.DM_NhaMays.SingleOrDefault(x => x.ID == HoatDong.ID && x.IDMADVIQLY == int.Parse(session.User.ma_dviqly));
         db.DM_NhaMays.DeleteOnSubmit(cv);
         db.SubmitChanges();
         _DataBind();
         ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Xoá người phụ trách thành công');", true);
     }
     catch (Exception ex)
     { }
     finally
     {
         e.Cancel = true;
     }
 }