Exemplo n.º 1
0
        protected void btnCapNhat_Click(object sender, EventArgs e)
        {
            DM_DVQLYService dm_dviSer = new DM_DVQLYService();
            SYS_Session     session   = (SYS_Session)Session["SYS_Session"];
            decimal         testSo    = 0;

            if (Session["Add"] + "" == "0")
            {
                var qtCT = (DataRowView)grdDVT.GetRow(grdDVT.FocusedRowIndex);

                //CBDN.DM_LoaiDay cn = db.DM_LoaiDays.SingleOrDefault(x => x.ID == qtCT.ID);
                if (!CheckName(txtMaLoaiDay.Text, int.Parse("" + qtCT["ID"])))
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Mã phương thức giao nhận được trùng');", true); return;
                }
                if (!decimal.TryParse(txtDienTro.Text, out testSo))
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Điện trở phải là kiểu số');", true); return;
                }
                db.Update_TTTT_DM_LOAIDUONGDAY(int.Parse("" + qtCT["ID"]), session.User.ma_dviqlyDN, txtMaLoaiDay.Text, txtTenLoaiDay.Text, int.Parse(cmbLoaiDay.Value + ""), decimal.Parse(txtDienTro.Value + ""), DateTime.Now, session.User.IDUSER);
            }
            else
            {
                if (!CheckName(txtMaLoaiDay.Text, 0))
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Mã phương thức giao nhận được trùng');", true); return;
                }
                if (!decimal.TryParse(txtDienTro.Text, out testSo))
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Điện trở phải là kiểu số');", true); return;
                }

                db.Insert_TTTT_DM_LOAIDUONGDAY(0, session.User.ma_dviqlyDN, txtMaLoaiDay.Text, txtTenLoaiDay.Text, int.Parse(cmbLoaiDay.Value + ""), decimal.Parse(txtDienTro.Value + ""), DateTime.Now, session.User.IDUSER);
            }
            pcAddRoles.ShowOnPageLoad = false;
            _DataBind();
        }