private void bind_data()
 {
     try
     {
         execSQL.execSQL ob = new execSQL.execSQL();
         DataSet ds = ob.fillDataset("EXEC CNT.BCPlan_getItem " + Request["id"]);
         lbKey.Text = ds.Tables[0].Rows[0][2].ToString();
         lbThangNam.Text = ds.Tables[0].Rows[0][1].ToString() + " _ KẾ HOẠCH " + ds.Tables[0].Rows[0][0].ToString();
         tbSapXep.Text = ds.Tables[0].Rows[0][3].ToString();
         tbTT.Text = ds.Tables[0].Rows[0][4].ToString();
         tbNoiDung.Text = ds.Tables[0].Rows[0][5].ToString();
         tbDV.Text = ds.Tables[0].Rows[0][6].ToString();
         tbKeHoach.Text = ds.Tables[0].Rows[0][7].ToString();
         tbThucHien.Text = ds.Tables[0].Rows[0][8].ToString();
         tbLuyKe.Text = ds.Tables[0].Rows[0][9].ToString();
         tbChuTri.Text = ds.Tables[0].Rows[0][10].ToString();
         tbDanhGia.Text = ds.Tables[0].Rows[0][11].ToString();
         tbNhanXet.Text = ds.Tables[0].Rows[0][12].ToString();
     }
     catch
     {
         lbKey.Text = "0";
         lbError.Text = "Có lỗi trong quá trình tải kế hoạch";
     }
 }
 protected void btCapNhat_Click(object sender, EventArgs e)
 {
     if (tbNoiDung.Text == "")
     {
         lbError.Text = "Chưa nhập nội dung kế hoạch";
         return;
     }
     try { Int32.Parse(tbSapXep.Text); }
     catch { tbSapXep.Text = "0"; }
     try { Int32.Parse(tbKeHoach.Text); }
     catch { tbKeHoach.Text = "0"; }
     try { Int32.Parse(tbThucHien.Text); }
     catch { tbThucHien.Text = "0"; }
     try { Int32.Parse(tbLuyKe.Text); }
     catch { tbLuyKe.Text = "0"; }
     try
     {
         string cmdTxt = string.Format("EXEC CNT.BCPlan_setItem {0}, {1}, {2}, N'{3}', N'{4}', N'{5}', {6}, {7}, {8}, N'{9}', N'{10}', N'{11}'",
             UserId, lbKey.Text, tbSapXep.Text, tbTT.Text, tbNoiDung.Text, tbDV.Text, tbKeHoach.Text,
             tbThucHien.Text, tbLuyKe.Text, tbChuTri.Text, tbDanhGia.Text, tbNhanXet.Text);
         execSQL.execSQL ob = new execSQL.execSQL();
         DataSet ds = ob.fillDataset(cmdTxt);
         if (ds.Tables[0].Rows[0][0].ToString() == "1") lbError.Text = "Cập nhật kế hoạch thành công";
         else lbError.Text = "Tài khoản không có quyền cập nhật kế hoạch này";
     }
     catch { lbError.Text = "Có lỗi trong quá trình cập nhật kế hoạch"; }
 }
 protected void btXem_Click(object sender, EventArgs e)
 {
     gvKeHoach.DataSource = null;
     gvKeHoach.DataBind();
     try
     {
         string donvi = "";
         foreach (GridViewRow row in gvPhongBan.Rows)
         {
             CheckBox cb = (CheckBox)row.FindControl("cbSelected");
             if (cb.Checked)
                 donvi = string.Format("{0}, ''{1}''", donvi, row.Cells[1].Text);
         }
         if (donvi.Length > 2)
         {
             donvi = string.Format("({0})", donvi.Remove(0, 2));
             string cmd = string.Format("EXEC CNT.BCPlan_TongHop '{0}', '{1}', '{2}', '{3}'",
                cbChon.Checked ? 1 : 0, rbKeHoach.SelectedValue, formatDate(tbThoiGian.Text), donvi);
             execSQL.execSQL ob = new execSQL.execSQL();
             gvKeHoach.DataSource = ob.fillDataset(cmd);
             gvKeHoach.DataBind();
         }
         else lbError.Text = "Chưa chọn đơn vị để tổng hợp";
     }
     catch (Exception ex) { lbError.Text = ex.Message; }
 }
 protected void btChuyen_Click(object sender, EventArgs e)
 {
     if (check_first_date() == 1)
     {
         execSQL.execSQL ob = new execSQL.execSQL();
         string cmd, planID;
         int ok = 0;
         foreach (GridViewRow row in gvKeHoach.Rows)
         {
             CheckBox cb = (CheckBox)row.FindControl("cbSelect");
             if (cb.Checked)
                 try
                 {
                     planID = row.Cells[1].Text;
                     cmd = string.Format("EXEC CNT.BCPlan_forward {0}, {1}, {2}, '{3}'", UserId, planID, rbKeHoach.SelectedValue, lbTime.Text);
                     DataSet ds = ob.fillDataset(cmd);
                     ok += int.Parse(ds.Tables[0].Rows[0][0].ToString());
                 }
                 catch { }
         }
         gvKeHoach.DataSource = null;
         gvKeHoach.DataBind();
         lbError.Text = string.Format("Chuyển thành công {0} kế hoạch", ok);
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack) return;
            hlRole.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "role", "mid/" + ModuleId);
            hlImport.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "import", "mid/" + ModuleId);
            hlTongHop.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "TONGHOP", "mid/" + ModuleId);
            hlLinhVuc.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "LINHVUC", "mid/" + ModuleId);
            hlGiaoBanTuan.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "GIAOBANTUAN", "mid/" + ModuleId);
            hlThongKe.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "THONGKE", "mid/" + ModuleId);

            if (Request["W"] != null)
                try { rbKeHoach.SelectedValue = Request["W"]; }
                catch { }

            execSQL.execSQL ob = new execSQL.execSQL();
            ddDonVi.DataSource = ob.fillDataset("EXEC CNT.BCPlan_getDonVi " + UserId).Tables[0];
            ddDonVi.DataBind();
            if (Request["W"] != null)
                try { ddDonVi.SelectedValue = Request["DV"]; }
                catch { }

            getThoiGian();
            if (Request["W"] != null)
                try { ddThoiGian.SelectedValue = Request["D"]; }
                catch { }

            getKeHoach();
        }
 protected void getThoiGian()
 {
     execSQL.execSQL ob = new execSQL.execSQL();
     //csClass ob = new csClass();
     ddThoiGian.DataSource = ob.fillDataset("EXEC CNT.BCPlan_getThoiGian " + rbKeHoach.SelectedValue);
     ddThoiGian.DataBind();
 }
 private void show_dropdown()
 {
     try
     {
         execSQL.execSQL ob = new execSQL.execSQL();
         ddThoiGian.DataSource = ob.fillDataset("EXEC CNT.BCPlan_getThoiGian " + rbKeHoach.SelectedValue);
         ddThoiGian.DataBind();
     }
     catch (Exception ex) { lbError.Text = ex.Message; }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack) return;
     try
     {
         execSQL.execSQL ob = new execSQL.execSQL();
         DataSet ds = ob.fillDataset("EOFFICE_PT", "EXEC bcPlan_week_getbyID 0, " + UserId);
         DateTime dt = DateTime.Parse(ds.Tables[0].Rows[0][0].ToString());
         lbThoiGian.Text = string.Format("Tuần từ {0} đến {1}", dt.ToString("dd/MM"), dt.AddDays(6).ToString("dd/MM/yyyy"));
     }
     catch { }
 }
        protected void gvKeHoach_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "CHON")
                try
                {
                    execSQL.execSQL ob = new execSQL.execSQL();
                    ob.fillDataset("EXEC CNT.BCPlan_TongHop_Update " + gvKeHoach.Rows[Convert.ToInt32(e.CommandArgument)].Cells[0].Text);

                    show_data();
                }
                catch (Exception ex) { lbError.Text = ex.Message; }
        }
 private void show_data()
 {
     try
     {
         execSQL.execSQL ob = new execSQL.execSQL();
         string cmd = string.Format("EXEC CNT.BCPlan_TongHop_Chon {0}, {1}, '{2}'", UserId, rbKeHoach.SelectedValue, ddThoiGian.SelectedValue);
         DataSet ds = ob.fillDataset(cmd);
         gvKeHoach.DataSource = ds.Tables[0];
         gvKeHoach.DataBind();
         lbError.Text = string.Format("Đã chọn: {0}/{1} kế hoạch", ds.Tables[1].Rows[0][0], ds.Tables[0].Rows.Count);
     }
     catch (Exception ex) { lbError.Text = ex.Message; }
 }
 protected void btCapNhat_Click(object sender, EventArgs e)
 {
     try
     {
         string cmdTxt = string.Format("EXEC CNT.BCPlan_Insert {0}, {1}, N'{2}', N'{3}', N'{4}', '{5}', '{6}', '{7}', N'{8}', N'{9}', N'{10}', {11}, '{12}'",
             UserId, Request["P"] == null ? "0" : Request["P"], tbTT.Text, tbNoiDung.Text, tbDV.Text, tbKeHoach.Text,
             tbThucHien.Text, tbLuyKe.Text, tbChuTri.Text, tbDanhGia.Text, tbNhanXet.Text, rbKeHoach.SelectedValue, rbTime.SelectedValue);
         execSQL.execSQL ob = new execSQL.execSQL();
         DataSet ds = ob.fillDataset(cmdTxt);
         if (ds.Tables[0].Rows[0][0].ToString() == "1")
             lbError.Text = "Cập nhật kế hoạch thành công. "+cmdTxt;
         else lbError.Text = "Không thể cập nhật kế hoạch";
     }
     catch { lbError.Text = "Có lỗi trong quá trình cập nhật kế hoạch"; }
 }
 protected int data_insert(GridViewRow row)
 {
     if (row.Cells[0].Text == "") return 0;
     try
     {
         string cmdTxt = string.Format("EXEC bcPlan_week_update {0}, {1}, N'{2}', N'{3}', N'{4}', '', '$CHUNGNT$'",
             0, 114, Server.HtmlDecode(row.Cells[0].Text), Server.HtmlDecode(row.Cells[1].Text), Server.HtmlDecode(row.Cells[2].Text));
         execSQL.execSQL ob = new execSQL.execSQL();
         //csClass ob = new csClass();
         DataSet ds = ob.fillDataset("EOFFICE_PT", cmdTxt);
         Response.Write(cmdTxt);
         if (ds.Tables[0].Rows[0][0].ToString() == "INS") return 1;
         else return 0;
     }
     catch { return 0; }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack) return;
     try
     {
         execSQL.execSQL ob = new execSQL.execSQL();
         string cmd = string.Format("EXEC CNT.BCPlan_getKeHoach {0}, '{1}', '{2}'", Request["week"], Request["madv"], Request["date"]);
         DataSet ds = ob.fillDataset(cmd);
         gvKeHoach.DataSource = ds;
         gvKeHoach.DataBind();
         lbDonVi.Text = real_name(ds.Tables[0].Rows[0]["TenDonVi"].ToString());
         lbPhongBan.Text = real_name(ds.Tables[0].Rows[0]["TenDonVi"].ToString());
         lbThangNam.Text = "Kế hoạch " + ds.Tables[0].Rows[0]["Thang"].ToString();
         lbNgayThang.Text = string.Format("Ngày {0} tháng {1} năm {2}", DateTime.Today.Day, DateTime.Today.Month, DateTime.Today.Year);
     }
     catch { lbError.Text = "Đơn vị không có kế hoạch trong tuần/tháng này"; }
 }
 protected void btInsert_Click(object sender, EventArgs e)
 {
     if (check_first_date() == 1)
     {
         string cmd = string.Format("EXEC CNT.BCPlan_delete {0}, {1}, '{2}'", UserId, rbKeHoach.SelectedValue, lbTime.Text);
         execSQL.execSQL ob = new execSQL.execSQL();
         ob.fillDataset(cmd);
         int ok = 0;
         foreach (GridViewRow dr in gvKeHoach.Rows)
         {
             ok += data_insert(dr);
         }
         gvKeHoach.DataSource = null;
         gvKeHoach.DataBind();
         lbError.Text = "Ghi thành công " + ok + " kế hoạch";
     }
 }
 private void bind_data()
 {
     try
     {
         execSQL.execSQL ob = new execSQL.execSQL();
         string cmd = string.Format("EXEC CNT.BCPlan_getKeHoach {0}, '{1}', '{2}'", Request["week"], Request["madv"], Request["date"]);
         gvKeHoach.DataSource = ob.fillDataset(cmd);
         gvKeHoach.DataBind();
         lbError.Text = "";
         rbKeHoach.SelectedValue = Request["week"];
         if (Request["week"] == "1")
         {
             int i = DayOfWeek.Monday - DateTime.Today.DayOfWeek;
             tbTime.Text = DateTime.Today.AddDays(i + 7).ToString("dd/MM/yyyy");
         }
         else
         {
             tbTime.Text = DateTime.Today.AddMonths(1).ToString("01/MM/yyyy");
         }
     }
     catch { lbError.Text = "Có lỗi trong quá trình đọc dữ liệu"; }
 }
 protected void getKeHoach()
 {
     hlPrint.NavigateUrl = string.Format("plan_print.aspx?madv={0}&date={1}&week={2}", ddDonVi.SelectedValue, ddThoiGian.SelectedValue, rbKeHoach.SelectedValue);
     hlChuyenTiep.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "forward", "mid/" + ModuleId,
         "week/" + rbKeHoach.SelectedValue, "madv/" + ddDonVi.SelectedValue, "date/" + ddThoiGian.SelectedValue);
     hlThemMoi.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "ADD", "mid/" + ModuleId, "W/" + rbKeHoach.SelectedValue);
     try
     {
         execSQL.execSQL ob = new execSQL.execSQL();
         //csClass ob = new csClass();
         string cmd = string.Format("EXEC CNT.BCPlan_getKeHoach {0}, '{1}', '{2}'", rbKeHoach.SelectedValue, ddDonVi.SelectedValue, ddThoiGian.SelectedValue);
         DataSet ds = ob.fillDataset(cmd);
         DataColumn dc = new DataColumn("EditLink");
         ds.Tables[0].Columns.Add(dc);
         dc = new DataColumn("AddLink");
         ds.Tables[0].Columns.Add(dc);
         ds.Tables[0].AcceptChanges();
         foreach (DataRow dr in ds.Tables[0].Rows)
         {
             dr.BeginEdit();
             dr["EditLink"] = DotNetNuke.Common.Globals.NavigateURL(TabId, "edit", "mid/" + ModuleId, "id/" + dr[0].ToString(),
                 "W/" + rbKeHoach.SelectedValue, "DV/" + ddDonVi.SelectedValue, "D/" + ddThoiGian.SelectedValue);
             dr["AddLink"] = DotNetNuke.Common.Globals.NavigateURL(TabId, "ADD", "mid/" + ModuleId, "P/" + dr[0].ToString(),
                 "W/" + rbKeHoach.SelectedValue, "DV/" + ddDonVi.SelectedValue, "D/" + ddThoiGian.SelectedValue);
             dr.EndEdit();
         }
         gvKeHoach.DataSource = ds.Tables[0];
         gvKeHoach.DataBind();
         lbTieuDe.Text = "KẾ HOẠCH " + ddThoiGian.SelectedItem.Text;
         if (ds.Tables[0].Rows.Count == 0)
             lbError.Text = "Không có kế hoạch";
         else
             lbError.Text = ds.Tables[0].Rows.Count + " kế hoạch";
     }
     catch (Exception ex) { lbError.Text = ex.Message; }
 }
 private void show_phongban()
 {
     execSQL.execSQL ob = new execSQL.execSQL();
     gvPhongBan.DataSource = ob.fillDataset("EXEC CNT.BCPlan_getDonVi 1");
     gvPhongBan.DataBind();
 }
 protected void btXoa_Click(object sender, EventArgs e)
 {
     try
     {
         string cmdTxt = string.Format("EXEC CNT.BCPlan_setItem {0}, {1}, 0, '', '', '', 0, 0, 0, '', '', '$DEL$'", UserId, lbKey.Text);
         execSQL.execSQL ob = new execSQL.execSQL();
         DataSet ds = ob.fillDataset(cmdTxt);
         if (ds.Tables[0].Rows[0][0].ToString() == "1") lbError.Text = "Xóa kế hoạch thành công";
         else lbError.Text = "Tài khoản không có quyền xóa kế hoạch này";
     }
     catch { lbError.Text = "Có lỗi trong quá trình xóa kế hoạch"; }
 }
 private int data_insert(GridViewRow row)
 {
     if (Server.HtmlDecode(row.Cells[1].Text).Length < 2) return 0;
     try
     {
         string cmdTxt = string.Format("EXEC CNT.BCPlan_import {0}, 0, N'{1}', N'{2}', N'{3}', '{4}', '{5}', '{6}', N'{7}', N'{8}', N'{9}', {10}, '{11}'",
             UserId, Server.HtmlDecode(row.Cells[0].Text), Server.HtmlDecode(row.Cells[1].Text), Server.HtmlDecode(row.Cells[2].Text),
             Server.HtmlDecode(row.Cells[3].Text), Server.HtmlDecode(row.Cells[4].Text), Server.HtmlDecode(row.Cells[5].Text), Server.HtmlDecode(row.Cells[6].Text),
             Server.HtmlDecode(row.Cells[7].Text), Server.HtmlDecode(row.Cells[8].Text), rbKeHoach.SelectedValue, lbTime.Text);
         execSQL.execSQL ob = new execSQL.execSQL();
         DataSet ds = ob.fillDataset(cmdTxt);
         if (ds.Tables[0].Rows[0][0].ToString() == "1") return 1;
         else return 0;
     }
     catch { return 0; }
 }