コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //loadDSGDV();
                HttpCookie ck = Request.Cookies["MaGDV"];
                if (ck == null)
                {
                    Response.Redirect("~/Pages/Login.aspx");
                }
                if (Session["ThamChieu"] != "")
                {
                    //load_CK();
                    string maclaim = Session["ThamChieu"].ToString();
                    maWR = wrdao.LayMa(maclaim);

                    //if (Session["MaWR"] != "")
                    if (maWR != 0)
                    {
                        //maWR = (int)Session["MaWR"];
                        LoadWRChiTiet(maWR);
                        //Session["MaWR"] = null;
                        lblThamChieu.Visible = true;
                        txtThamChieu.Visible = false;
                    }
                    else
                    {
                        //string idclaim = cldao.LayMaTheoTen(maclaim);
                        txtThamChieu.Visible = false;
                        lblThamChieu.Visible = true;
                        lblThamChieu.Text    = maclaim;
                        maWR = wrdao.LayMa(maclaim);
                        LoadWRChiTiet(maWR);
                    }
                }
            }
        }
コード例 #2
0
        protected void btnCapNhat_Click(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                string maclaim = "";
                if (lblThamChieu.Text != "")
                {
                    maclaim = lblThamChieu.Text;
                }
                if (txtThamChieu.Text != "")
                {
                    maclaim = txtThamChieu.Text;
                }
                bool kq = wrdao.KiemTraWR(maclaim);
                bool kt = tsdao.KiemTraTimeSheetTonTai(maclaim);
                if (kq == false)    //chua co weekly report
                {
                    //them moi wr
                    maclaim       = txtThamChieu.Text;
                    wrdto.MaClaim = maclaim;
                    //wrdto.MaGDV = int.Parse(drGDV.SelectedValue);
                    if (kt == true)
                    {
                        float gio = tsdao.TongThoiLuongPhatSinhTheoCliam(maclaim);
                        wrdto.GioTichLuy = gio;
                    }
                    else
                    {
                        wrdto.GioTichLuy = (float)0;
                    }

                    string dexuatgiamdinh = ckDeXuatGiamDinh.Text;
                    if (dexuatgiamdinh != "")
                    {
                        wrdto.DeXuatGiamDinh = dexuatgiamdinh;
                    }
                    else
                    {
                        wrdto.DeXuatGiamDinh = "";
                    }

                    bool kqt = wrdao.Them(wrdto);
                    if (kqt == true)
                    {
                        string thamchieu = cldao.TenClaim(maclaim);
                        Session["ThamChieu"] = thamchieu;
                        Response.Redirect("~/Pages/XemWeeklyReport.aspx?viewthamchieu=" + thamchieu);
                    }
                }
                else
                {
                    //cap nhat wr
                    wrdto    = new WeeklyReportDTO();
                    wrdto.Ma = wrdao.LayMa(maclaim);
                    //wrdto.DuPhongTonThat = txtDuPhongTonThat.Text.Trim();
                    wrdto.DeXuatGiamDinh = ckDeXuatGiamDinh.Text.Trim();
                    //wrdto.GioTichLuy = float.Parse(txtGioTichLuy.Text);
                    bool kqcn = wrdao.CapNhat(wrdto);
                    if (kqcn == true)
                    {
                        string tc = cldao.TenClaim(maclaim);
                        Session["ThamChieu"] = tc;
                        Response.Redirect("~/Pages/XemWeeklyReport.aspx?viewthamchieu=" + tc);
                        //Response.RedirectLocation("~/Pages/ViewWR.aspx");
                    }
                }
                //}
                //else
                //    lblThongBao.Text = "Sai tham chiếu.";
                //}
                //else
                //    lblThongBao.Text = "Chưa nhập tham chiếu.";
            }
        }