예제 #1
0
        protected void btnUpdateVaoBoPhan_Click(object sender, EventArgs e)
        {
            foreach (GridViewRow item in dtgUsers.Rows)
            {
                CheckBox chk   = (CheckBox)item.FindControl("chkCheck");
                Label    lblID = (Label)item.FindControl("lblID");

                int id = ConvertUtility.ToInt32(lblID.Text);

                if (chk.Checked)
                {
                    QuanLyCongViecBaoCaoNgayController.UpdateStatus(id, 1);
                    QuanLyCongViecBaoCaoNgayInfo info = QuanLyCongViecBaoCaoNgayController.GetInfo(id);
                    QuanLyCongViecBaoCaoNgayController.InsertBaoCaoNgayBoPhan(info);
                }
                else
                {
                    QuanLyCongViecBaoCaoNgayController.UpdateStatus(id, 0);
                }
            }
        }
        protected void cmdDel_Click(object sender, EventArgs e)
        {
            try
            {
                QuanLyCongViecBaoCaoNgayController.Delete(ConvertUtility.ToInt32(txtID.Text));

                int ParentID = ConvertUtility.ToInt32(dropCongViecKPI.SelectedValue);
                if (ParentID > 0)
                {
                    QuanLyCongViecBaoCaoNgayInfo info = QuanLyCongViecBaoCaoNgayController.GetInfo(ConvertUtility.ToInt32(txtID.Text));
                    if (info == null)
                    {
                        cmdEmpty_Click(null, null);
                        return;
                    }

                    string oldData = GetObjectInfo(info);

                    #region Log Action

                    LogFileInfo logFileInfo = new LogFileInfo();
                    logFileInfo.Log_Action         = "Delete";
                    logFileInfo.Log_Type_Object    = "QuanLyCongViecKPITheoNgay";
                    logFileInfo.Item_CatID         = "Cong Viec Thuong Xuyen";
                    logFileInfo.Item_ID            = info.ID.ToString();
                    logFileInfo.Item_Name          = info.Ten;
                    logFileInfo.Description_Before = "Old Data: " + oldData;
                    logFileInfo.Description_After  = "Delete KPI with info: <br />" + GetObjectInfo(info);
                    logFileInfo.UserName           = CurrentUser.Username;
                    logFileInfo.UserID             = CurrentUser.UserID;
                    CreateLogFile.LogAction(logFileInfo);

                    #endregion
                }
            }
            catch (Exception ex)
            {
                lblStatusUpdate.Text = ex.Message;
            }
        }
        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            QuanLyCongViecBaoCaoNgayInfo info = QuanLyCongViecBaoCaoNgayController.GetInfo(ConvertUtility.ToInt32(txtID.Text));

            if (info == null)
            {
                cmdEmpty_Click(null, null);
                return;
            }
            if (info.ID == ConvertUtility.ToInt32(dropCongViecKPI.SelectedValue))
            {
                lblStatusUpdate.Text = "Trung mục cha";
                return;
            }
            string oldData = GetObjectInfo(info);

            info.IDCongViecKPI = ConvertUtility.ToInt32(dropCongViecKPI.SelectedValue);
            info.Ten           = txtName.Text;
            info.KeHoach       = txtKeHoach.Text;
            info.ParentID      = txtCongViecLon.Text;
            info.TyTrong       = 0;// ConvertUtility.ToDouble(txtTyTrong.Text);
            info.KetQua        = txtKetqua.Text;
            info.TyLeHoanThanh = dropTyLeHoanThanh.SelectedValue;
            info.IDTrungTam    = CurrentUser.IDTrungTam;
            info.IDPhongBan    = CurrentUser.IDPhong;
            info.IDDotDanhGia  = ConvertUtility.ToInt32(dropDotDanhGia.SelectedValue);
            info.SoGio         = ConvertUtility.ToDouble(txtSoGio.Text);
            info.CreateBy      = CurrentUser.UserID;
            info.LyDo          = txtLyDo.Text;
            info.DeXuat        = txtDeXuat.Text;
            info.CreatedOn     = new DateTime(ConvertUtility.ToInt32(dropYear.SelectedValue), ConvertUtility.ToInt32(dropMonth.SelectedValue), ConvertUtility.ToInt32(dropDay.SelectedValue));
            try
            {
                QuanLyCongViecBaoCaoNgayController.Update(info);

                lblStatusUpdate.Text = MiscUtility.MSG_UPDATE_SUCCESS;

                #region Log Action

                LogFileInfo logFileInfo = new LogFileInfo();
                logFileInfo.Log_Action         = "Update";
                logFileInfo.Log_Type_Object    = "QuanLyCongViecKPITheoNgay";
                logFileInfo.Item_CatID         = "Cong Viec Thuong Xuyen";
                logFileInfo.Item_ID            = info.ID.ToString();
                logFileInfo.Item_Name          = info.Ten;
                logFileInfo.Description_Before = "Old Data: " + oldData;
                logFileInfo.Description_After  = "Update KPI with info: <br />" + GetObjectInfo(info);
                logFileInfo.UserName           = CurrentUser.Username;
                logFileInfo.UserID             = CurrentUser.UserID;
                CreateLogFile.LogAction(logFileInfo);

                #endregion

                cmdEmpty_Click(null, null);
                //Response.Redirect(AppEnv.AdminUrlParams("baocaongay"));
            }
            catch (Exception ex)
            {
                lblStatusUpdate.Text = ex.Message;
            }
        }
        private void LoadInfo(int id)
        {
            QuanLyCongViecBaoCaoNgayInfo info = QuanLyCongViecBaoCaoNgayController.GetInfo(id);

            if (info == null)
            {
                cmdEmpty_Click(null, null);
                return;
            }

            if (info.CreatedOn.Year != DateTime.Now.Year || info.CreatedOn.Month != DateTime.Now.Month || info.CreatedOn.Day < DateTime.Now.Day)
            {
                txtName.ReadOnly    = true;
                txtKeHoach.ReadOnly = true;
                //txtTyTrong.ReadOnly = true;
                txtKetqua.ReadOnly        = true;
                txtCongViecLon.ReadOnly   = true;
                dropTyLeHoanThanh.Enabled = false;
                txtLyDo.ReadOnly          = true;
                txtDeXuat.ReadOnly        = true;
                //dropPhong.Enabled = false;
                txtSoGio.ReadOnly = true;
            }
            else
            {
                txtName.ReadOnly    = false;
                txtKeHoach.ReadOnly = false;
                //txtTyTrong.ReadOnly = false;
                txtKetqua.ReadOnly        = false;
                txtCongViecLon.ReadOnly   = true;
                dropTyLeHoanThanh.Enabled = true;
                txtLyDo.ReadOnly          = false;
                txtDeXuat.ReadOnly        = false;
                //dropPhong.Enabled = true;
                txtSoGio.ReadOnly = false;
            }

            try
            {
                dropCongViecKPI.SelectedValue = info.IDCongViecKPI.ToString();
            }
            catch (Exception)
            {
                dropCongViecKPI.SelectedIndex = 0;
            }

            txtID.Text      = info.ID.ToString();
            txtName.Text    = info.Ten;
            txtKeHoach.Text = info.KeHoach;
            //txtTyTrong.Text = Math.Round(info.TyTrong, 3).ToString().Replace(".", ",");
            txtKetqua.Text      = info.KetQua;
            txtCongViecLon.Text = info.ParentID;

            dropTyLeHoanThanh.SelectedValue = info.TyLeHoanThanh;
            txtLyDo.Text   = info.LyDo;
            txtDeXuat.Text = info.DeXuat;
            //try
            //{
            //    dropPhong.SelectedValue = info.IDPhongBan.ToString();
            //}
            //catch (Exception)
            //{
            //    dropPhong.SelectedIndex = -1;
            //}

            try
            {
                txtSoGio.Text = info.SoGio.ToString();
            }
            catch (Exception)
            {
                txtSoGio.Text = "";
            }

            dropYear.SelectedValue  = info.CreatedOn.Year.ToString();
            dropMonth.SelectedValue = info.CreatedOn.Month.ToString();
            dropDay.SelectedValue   = info.CreatedOn.Day.ToString();
        }