protected void Button1_Click(object sender, EventArgs e)
    {
        BWork bll = new BWork();
        Work  w   = new Work(
            Convert.ToString(TextBox2.Text),
            Convert.ToDateTime(System.DateTime.Now),
            Convert.ToBoolean(RadioButton1.Text),
            Convert.ToString(TextBox5.Text),
            Convert.ToInt16(TextBox1.Text),
            true,
            Convert.ToString(DropDownList1.Text)

            );

        //    BHomework bh= new BHomework();
        //    Homework s = new Homework(
        //    Convert.ToString(DropDownList2.Text),
        //    Convert.ToString(TextBox5.Text),
        //    Convert.ToInt16(TextBox1.Text),
        //    Convert.ToString(TextBox2.Text),
        //    Convert.ToString(DropDownList1.Text ),
        //    Convert.ToDateTime(TextBox3.Text),
        //    Convert.ToDateTime(TextBox4.Text),
        //    false
        //    );

        if (Page.IsValid)
        {
            //bh.UpdateHomework (s);
            bll.InsertWork(w);
            Response.Write("<script>alert('暂存成功!');location='WorkAdd.aspx'</script>");
        }
    }
Example #2
0
        protected void Infomation_Load()
        {
            int WorkID = int.Parse(Request.QueryString["WorkID"].ToString());

            BWork Bobj = new BWork();
            OWork obj  = new OWork();

            obj = Bobj.GetWork(WorkID).First();

            lblName.Text        = obj.Name;
            lblNgayTao.Text     = obj.CreateDate.ToString("dd/MM/yyyy");
            lblNgayBatDau.Text  = obj.StartProcess.ToString("dd/MM/yyyy");
            lblNgayKetThuc.Text = obj.EndProcess.ToString("dd/MM/yyyy");
            lblYeuCau.Text      = obj.Description;

            rptListUser.DataSource = Bobj.GetUserProcess(WorkID);
            rptListUser.DataBind();

            //Lấy file Attachs
            string list = obj.Attachs.ToString();

            string[] item;
            item = list.Split(',');

            rptFiles.DataSource = Bobj.GetAttachs(WorkID);
            rptFiles.DataBind();

            if (obj.Attachs == "" || obj.Attachs == ",")
            {
                lblThongBao.Text = "Không có file đính kèm!";
            }
        }
        protected void btnGiaoViec_Click(object sender, EventArgs e)
        {
            int   UserID = Global.UserInfo.UserID;
            BWork obj    = new BWork();
            OWork _OWork = new OWork();

            foreach (GridViewRow row in grvWork.Rows)
            {
                CheckBox checkbox = (CheckBox)row.FindControl("MyCheckBox");

                if (checkbox.Checked == true)
                {
                    int Id = Convert.ToInt32(grvWork.DataKeys[row.RowIndex].Value);
                    _OWork = obj.GetWork(Id).First();
                    if (_OWork.Status == "CHUA_GIAO")
                    {
                        if (!obj.Update(Id, "DANG_THUC_HIEN", UserID))
                        {
                            RegisterClientScriptBlock("NOTE", "<script>alert('Công việc chưa được giao !');</script>");
                        }
                    }
                }
            }
            grvWork_Load();
        }
Example #4
0
        protected void InitData()
        {
            ddlWorkGroup_Load();
            BindDepartment();

            BWork _BWork = new BWork();
            OWork _OWork = new OWork();
            int   WorkID = int.Parse(Request.QueryString["WorkID"].ToString());

            _OWork = _BWork.GetWork(WorkID).First();
            ddlWorkGroup.SelectedValue = _OWork.IDWorkGroup.ToString();
            txtWorkName.Text           = _OWork.Name;
            txtContent.Text            = _OWork.Content;
            txtDescription.Text        = _OWork.Description;
            txtStartDate.Text          = _OWork.StartProcess.ToString("dd/MM/yyyy");
            txtEndDate.Text            = _OWork.EndProcess.ToString("dd/MM/yyyy");

            //Lấy file Attachs
            string list = _OWork.Attachs.ToString();

            string[] item;
            item = list.Split(',');

            rptFiles.DataSource = _BWork.GetAttachs(WorkID);
            rptFiles.DataBind();

            if (_OWork.Attachs == "" || _OWork.Attachs == ",")
            {
                lblThongBao.Text = "Không có file đính kèm!";
            }

            hdfUserJoin.Value = _OWork.IDUserProcess;
        }
        protected string BindNgayGiao(string WorkID)
        {
            string   str = string.Empty;
            DateTime time;
            BWork    obj = new BWork();

            time = obj.GetWork(int.Parse(WorkID)).First().StartProcess;
            str  = time.Day.ToString() + "/" + time.Month.ToString() + "/" + time.Year.ToString();
            return(str);
        }
        protected string BindNgayTao(string WorkID)
        {
            string time    = string.Empty;
            BWork  obj     = new BWork();
            OWork  objWork = new OWork();

            objWork = obj.GetWork(int.Parse(WorkID)).First();
            time    = objWork.CreateDate.Day.ToString() + "/" + objWork.CreateDate.Month.ToString() + "/" + objWork.CreateDate.Year.ToString();
            return(time);
        }
Example #7
0
 public void rptItemCommand(object sender, RepeaterCommandEventArgs e)
 {
     //Response.Write(e.CommandName);
     //Response.Write(e.CommandArgument);
     if (e.CommandName == "Download")
     {
         try
         {
             HttpContext.Current.Response.ContentType =
                 "application/octet-stream";
             HttpContext.Current.Response.AddHeader("Content-Disposition",
                                                    "attachment; filename=" + System.IO.Path.GetFileName(Server.MapPath(e.CommandArgument.ToString())));
             HttpContext.Current.Response.Clear();
             HttpContext.Current.Response.WriteFile(Server.MapPath(e.CommandArgument.ToString()));
             HttpContext.Current.Response.End();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
     if (e.CommandName == "Delete")
     {
         int     WorkID       = int.Parse(Request.QueryString["WorkID"].ToString());
         OAttach objAttach    = new OAttach();
         BAttach BobjAttach   = new BAttach();
         BWork   BobjWork     = new BWork();
         OWork   objWork      = BobjWork.GetWork(WorkID).First();
         int     IDUserCreate = int.Parse(objWork.IDUserCreate.ToString());
         string  listAttach   = objWork.Attachs.ToString();
         objAttach = BobjAttach.Get(int.Parse(e.CommandArgument.ToString())).First();
         string AttachId = objAttach.AttachID.ToString();
         try
         {
             FileInfo TheFile = new FileInfo(Server.MapPath(objAttach.Path));
             if (TheFile.Exists)
             {
                 File.Delete(Server.MapPath(objAttach.Path)); //Xóa file Attach
                 BobjAttach.Delete(objAttach.AttachID);       //Xóa file Attach trong CSDL
                 string newListAttach = listAttach.Replace("," + AttachId + ",", ",");
                 BobjWork.UpdateAttach(WorkID, newListAttach, IDUserCreate);
                 Infomation_Load();
             }
             else
             {
                 throw new FileNotFoundException();
             }
         }
         catch (Exception ex)
         {
             //throw new FileNotFoundException();
         }
     }
 }
        /// <summary>
        /// Hàm ghép chuỗi thời gian bắt đầu và kết thúc
        /// </summary>
        /// <param name="WorkID"></param>
        /// <returns></returns>
        protected string BindThoiGian(string WorkID)
        {
            string time    = string.Empty;
            BWork  obj     = new BWork();
            OWork  objWork = new OWork();

            objWork = obj.GetWork(int.Parse(WorkID)).First();
            time    = objWork.StartProcess.Day.ToString() + "/" + objWork.StartProcess.Month.ToString() + "/" + objWork.StartProcess.Year.ToString();
            time   += " - " + objWork.EndProcess.Day.ToString() + "/" + objWork.EndProcess.Month.ToString() + "/" + objWork.EndProcess.Year.ToString();
            return(time);
        }
        /// <summary>
        /// Lấy ra trạng thái công việc giao tương ứng với công việc
        /// </summary>
        /// <param name="WorkID"></param>
        /// <returns></returns>
        protected string BindTrangThai(string WorkID)
        {
            string status  = string.Empty;
            BWork  obj     = new BWork();
            OWork  objWork = new OWork();

            objWork = obj.GetWork(int.Parse(WorkID)).First();
            NameValueCollection appSettings = WebConfigurationManager.AppSettings as NameValueCollection;

            status = appSettings[objWork.Status];
            return(status);
        }
        protected void btnXoa_Click(object sender, EventArgs e)
        {
            BWork obj = new BWork();

            foreach (GridViewRow row in grvWork.Rows)
            {
                CheckBox checkbox = (CheckBox)row.FindControl("MyCheckBox");

                if (checkbox.Checked == true)
                {
                    int Id = Convert.ToInt32(grvWork.DataKeys[row.RowIndex].Value);
                    obj.Delete(Id);
                }
            }
            grvWork_Load();
        }
        protected string BindTrangThai(string WorkID)
        {
            string status  = string.Empty;
            BWork  obj     = new BWork();
            OWork  objWork = new OWork();

            objWork = obj.GetWork(int.Parse(WorkID)).First();
            if (objWork.Status == "CONG_VIEC_DA_XU_LY")
            {
                status = "Công việc đã xử lý";
            }
            if (objWork.Status == "DANG_THUC_HIEN")
            {
                status = "Công việc cần xử lý";
            }

            return(status);
        }
        protected void btnTiepTuc_Click(object sender, EventArgs e)
        {
            int   UserID = Global.UserInfo.UserID;
            BWork obj    = new BWork();

            foreach (GridViewRow row in grvWork.Rows)
            {
                CheckBox checkbox = (CheckBox)row.FindControl("MyCheckBox");

                if (checkbox.Checked == true)
                {
                    int Id = Convert.ToInt32(grvWork.DataKeys[row.RowIndex].Value);
                    if (obj.GetWork(Id).First().Status == "DUNG_XU_LY")
                    {
                        obj.Update(Id, "DANG_THUC_HIEN", UserID);
                    }
                }
            }
            grvWork_Load();
        }
        protected void lbtnForward_Click(object sender, EventArgs e)
        {
            // Retrieve control
            LinkButton lbtnForward = sender as LinkButton;

            int WorkID = Int32.Parse(lbtnForward.CommandArgument);

            BWork _BWork = new BWork();
            OWork _OWork = new OWork();

            _OWork = _BWork.GetWork(WorkID).First();
            if (_OWork.Status == "CHUA_GIAO")
            {
                Response.Redirect("EditAssignment.aspx?WorkID=" + WorkID);
            }
            else
            {
                Response.Redirect("WorkAssignmentDetail.aspx?WorkID=" + WorkID);
            }
        }
        protected void grvWork_Load()
        {
            int    UserID         = Global.UserInfo.UserID;
            BWork  objWork        = new BWork();
            string _name          = "";
            string _idUserProcess = "";
            int    _workgroup     = int.Parse(ddlWorkGroup.SelectedValue);
            string _status        = ddlWork.SelectedValue;

            //--Set key tìm kiếm
            if (txtKeyword.Text.Trim().Length > 0)
            {
                switch (ddlTieuChi.SelectedValue)
                {
                case "WorkName":
                    _name = txtKeyword.Text.Trim();
                    break;

                case "User":
                    _idUserProcess = txtKeyword.Text.Trim();
                    break;
                }
            }
            ctlPagging.PageSize = int.Parse(ddlPageSize.SelectedValue);
            int count = objWork.Get(_name, _status, _workgroup, _idUserProcess).Count;

            spResultCount.InnerHtml = "Tìm thấy <b>" + count.ToString() + "</b> kết quả";
            if (count > ctlPagging.PageSize)
            {
                ctlPagging.Visible = true;
            }
            else
            {
                ctlPagging.Visible = false;
            }
            grvWork.DataSource = objWork.Get(_name, _status, _workgroup, _idUserProcess, "ASC", "Name", CurrentPage, ctlPagging.PageSize);
            grvWork.DataBind();
            ctlPagging.CurrentIndex             = CurrentPage;
            ctlPagging.ItemCount                = count;
            ctlPagging.QueryStringParameterName = GenarateParam();
        }
Example #15
0
        protected void btnCapNhat_Click(object sender, EventArgs e)
        {
            BWork  BobjWork = new BWork();
            string Status   = string.Empty;

            if (rdoTiepTuc.Checked)
            {
                Status = "DANG_THUC_HIEN";
            }
            if (rdoTamDung.Checked)
            {
                Status = "DUNG_XU_LY";
            }
            if (rdoHoanThanh.Checked)
            {
                Status = "CONG_VIEC_DA_XU_LY";
            }
            int WorkID       = int.Parse(Request.QueryString["WorkID"].ToString());
            int IDUserCreate = BobjWork.Get(WorkID).First().IDUserCreate;

            BobjWork.Update(WorkID, Status, IDUserCreate);
        }
Example #16
0
        protected void btnCapNhat_Click(object sender, EventArgs e)
        {
            BWork BobjWork = new BWork();
            //Lấy IDWWork
            int WorkID = int.Parse(Request.QueryString["WorkID"].ToString());
            //Lấy IDUserCreate
            string IDUserCreate = Global.UserInfo.UserName;//Lấy lại sau
            //Lấy nội dung xử lý
            string Content = txtContent.Text;
            //Upload File
            DateTime CurrentTime = DateTime.Now;
            string   day         = CurrentTime.Day.ToString();
            string   month       = CurrentTime.Month.ToString();
            string   year        = CurrentTime.Year.ToString();
            string   hour        = CurrentTime.Hour.ToString();
            string   minute      = CurrentTime.Minute.ToString();
            string   millisecond = CurrentTime.Millisecond.ToString();
            string   str         = "-" + day + "-" + month + "-" + year + "-" + "-" + hour + "-" + minute + "-" + millisecond;
            //Lấy danh sách file đính kèm
            BAttach            Bobj = new BAttach();
            HttpFileCollection hfc  = Request.Files;
            int    n        = hfc.Count;
            string listFile = ",";

            if (n > 0)
            {
                try
                {
                    // Get the HttpFileCollection

                    for (int i = 0; i < hfc.Count; i++)
                    {
                        HttpPostedFile hpf = hfc[i];
                        if (hpf.ContentLength > 0)
                        {
                            hpf.SaveAs(Server.MapPath("/MyFiles") + "/" + System.IO.Path.GetFileNameWithoutExtension(hpf.FileName).Replace(" ", "_") + str + System.IO.Path.GetExtension(hpf.FileName));
                            OAttach obj = new OAttach();
                            obj.Name        = System.IO.Path.GetFileName(hpf.FileName);
                            obj.Path        = "~/MyFiles" + "/" + System.IO.Path.GetFileNameWithoutExtension(hpf.FileName).Replace(" ", "_") + str + System.IO.Path.GetExtension(hpf.FileName);
                            obj.Description = "";
                            Bobj.Add(obj);
                            listFile += Bobj.GetLast().FirstOrDefault().AttachID.ToString() + ",";
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
            //Lấy danh sách người chuyển tiếp
            string UserJoin = hdfUsers.Value;

            if (UserJoin == ",")
            {
                UserJoin = "";
            }

            //////////////////////////////////////////////
            //Tạo Comment mới
            BComment BobjComment = new BComment();
            OComment objComment  = new OComment();

            objComment.CommentID    = WorkID.ToString() + "" + CurrentTime.ToString();
            objComment.Title        = "Xử lý công việc: " + BobjWork.GetWork(WorkID).First().Name;
            objComment.Content      = Content;
            objComment.IDUserCreate = IDUserCreate;
            objComment.IDDocument   = "";
            objComment.IDWork       = WorkID;
            objComment.Attachs      = listFile;
            objComment.CreateDate   = CurrentTime;

            BobjComment.Add(objComment);

            //Thêm danh sách người chuyển tiếp nếu có chuyển tiếp

            if (UserJoin != "")
            {
                OWork objWork = new OWork();
                objWork = BobjWork.GetWork(WorkID).First();
                //Xử lý người chuyển tiếp trùng lặp
                string CurrentList = objWork.IDUserProcess;

                string[] divUser = UserJoin.Split(',');

                for (int i = 0; i < divUser.Count(); i++)
                {
                    divUser[i]  = "," + divUser[i] + ",";
                    CurrentList = CurrentList.Replace(divUser[i], ",");
                }
                string newlistUserProcess = CurrentList + UserJoin;
                BobjWork.UpdateUserProcess(WorkID, newlistUserProcess, objWork.IDUserCreate);   //Lấy IDUserCreate sau
            }

            Page.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
        }
Example #17
0
        public void DecompressEntry(sfarFile entry, Stream input, Stream output)
        {
#endif
            int count = 0;

            byte[] inputBlock;
            byte[] outputBlock = new byte[MaximumBlockSize];

            var left = entry.uncompressedSize;

            input.Seek(entry.dataOffset[0], SeekOrigin.Begin);

            if (entry.blockSizeIndex == -1)
            {
                output.WriteFromStream(input, entry.uncompressedSize);
            }
            else
            {
                while (left > 0)
                {
                    uint compressedBlockSize = entry.blockSizeArray[count];
                    if (compressedBlockSize == 0)
                    {
                        compressedBlockSize = MaximumBlockSize;
                    }

                    if (CompressionScheme == CompressionScheme.None)
                    {
                        output.WriteFromStream(input, compressedBlockSize);
                        left -= compressedBlockSize;
                    }
                    else if (CompressionScheme == CompressionScheme.Lzma)
                    {
                        if (compressedBlockSize == MaximumBlockSize ||
                            compressedBlockSize == left)
                        {
                            output.WriteFromStream(input, compressedBlockSize);
                            left -= compressedBlockSize;
                        }
                        else
                        {
                            var uncompressedBlockSize = (uint)Math.Min(left, MaximumBlockSize);

                            if (compressedBlockSize < 5)
                            {
                                throw new InvalidOperationException();
                            }

                            inputBlock = new byte[compressedBlockSize];

                            //var properties = input.ReadBytes(5);
                            //compressedBlockSize -= 5;

                            if (input.Read(inputBlock, 0, (int)compressedBlockSize)
                                != compressedBlockSize)
                            {
                                throw new EndOfStreamException();
                            }

                            uint actualUncompressedBlockSize = uncompressedBlockSize;
                            uint actualCompressedBlockSize   = compressedBlockSize;

                            /*var error = LZMA.Decompress(
                             *  outputBlock,
                             *  ref actualUncompressedBlockSize,
                             *  inputBlock,
                             *  ref actualCompressedBlockSize,
                             *  properties,
                             *  (uint)properties.Length);
                             *
                             * if (error != LZMA.ErrorCode.Ok ||
                             *  uncompressedBlockSize != actualUncompressedBlockSize ||
                             *  compressedBlockSize != actualCompressedBlockSize)
                             * {
                             *  throw new InvalidOperationException();
                             * }*/

                            outputBlock = SevenZipHelper.LZMA.Decompress(inputBlock, actualUncompressedBlockSize);
                            if (outputBlock.Length != actualUncompressedBlockSize)
                            {
                                throw new NotImplementedException();
                            }

                            output.Write(outputBlock, 0, (int)actualUncompressedBlockSize);
                            left -= uncompressedBlockSize;

#if (WITH_GUI)
                            if (BWork != null)
                            {
                                int perc = (int)(count / (float)entry.blockSizeArray.Length * 100);
                                if (perc > maxPerc)
                                {
                                    maxPerc = perc;
                                    BWork.ReportProgress(perc);
                                }
                            }
#endif
                        }
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                    count++;
                }
            }
        }// end of DecompressEntry
Example #18
0
        protected void btnForward_Click(object sender, EventArgs e)
        {
            //Gửi thông báo tới người thực hiện công việc


            //Upload File
            CultureInfo culture = new CultureInfo("fr-FR", true);

            //Upload File
            DateTime CurrentTime = DateTime.Now;
            string   day         = CurrentTime.Day.ToString();
            string   month       = CurrentTime.Month.ToString();
            string   year        = CurrentTime.Year.ToString();
            string   hour        = CurrentTime.Hour.ToString();
            string   minute      = CurrentTime.Minute.ToString();
            string   millisecond = CurrentTime.Millisecond.ToString();
            string   str         = "-" + day + "-" + month + "-" + year + "-" + "-" + hour + "-" + minute + "-" + millisecond;

            //Lấy danh sách file Attach
            BAttach            Bobj = new BAttach();
            HttpFileCollection hfc  = Request.Files;
            int    n        = hfc.Count;
            string listFile = ",";

            try
            {
                // Get the HttpFileCollection

                for (int i = 0; i < hfc.Count; i++)
                {
                    HttpPostedFile hpf = hfc[i];
                    if (hpf.ContentLength > 0)
                    {
                        hpf.SaveAs(Server.MapPath("/MyFiles") + "/" + System.IO.Path.GetFileNameWithoutExtension(hpf.FileName).Replace(" ", "_") + str + System.IO.Path.GetExtension(hpf.FileName));
                        OAttach obj = new OAttach();
                        obj.Name        = System.IO.Path.GetFileName(hpf.FileName);
                        obj.Path        = "~/MyFiles" + "/" + System.IO.Path.GetFileNameWithoutExtension(hpf.FileName).Replace(" ", "_") + str + System.IO.Path.GetExtension(hpf.FileName);
                        obj.Description = "";
                        Bobj.Add(obj);
                        listFile += Bobj.GetLast().FirstOrDefault().AttachID.ToString() + ",";
                    }
                }
            }
            catch (Exception ex)
            {
            }


            //Lấy danh sách người thực hiện công việc

            string UserJoin = hdfUsers.Value;

            if (UserJoin == ",")
            {
                UserJoin = "";
            }
            else
            {
                UserJoin = "," + UserJoin;
            }
            //Lấy mức độ ưu tiên
            string Priority = string.Empty;

            if (rdoPrior1.Checked == true)
            {
                Priority = "RAT_QUAN_TRONG";
            }
            else if (rdoPrior2.Checked == true)
            {
                Priority = "QUAN_TRONG";
            }
            else
            {
                Priority = "BINH_THUONG";
            }

            //Lưu công việc mới
            OWork objWork = new OWork();

            objWork.Name          = txtWorkName.Text;
            objWork.Description   = txtDescription.Text;
            objWork.Content       = txtContent.Text;
            objWork.Attachs       = listFile;
            objWork.IDUserCreate  = Global.UserInfo.UserID;  //--Lấy IDUserCreate sau
            objWork.IDUserProcess = UserJoin;
            objWork.IDWorkGroup   = int.Parse(ddlWorkGroup.SelectedValue);
            objWork.CreateDate    = CurrentTime;
            objWork.Status        = "DANG_THUC_HIEN";
            objWork.Priority      = Priority;
            objWork.StartProcess  = DateTime.Parse(txtStartDate.Text, culture, DateTimeStyles.NoCurrentDateDefault);
            objWork.EndProcess    = DateTime.Parse(txtEndDate.Text, culture, DateTimeStyles.NoCurrentDateDefault);

            BWork BobjWork = new BWork();

            BobjWork.Add(objWork);

            //Reset Field
            ResetField();
            RegisterClientScriptBlock("NOTE", "<script>alert('Công việc đã được giao !');</script>");
        }
Example #19
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            CultureInfo culture = new CultureInfo("fr-FR", true);

            //Upload File
            DateTime CurrentTime = DateTime.Now;
            string   day         = CurrentTime.Day.ToString();
            string   month       = CurrentTime.Month.ToString();
            string   year        = CurrentTime.Year.ToString();
            string   hour        = CurrentTime.Hour.ToString();
            string   minute      = CurrentTime.Minute.ToString();
            string   millisecond = CurrentTime.Millisecond.ToString();
            string   str         = "-" + day + "-" + month + "-" + year + "-" + "-" + hour + "-" + minute + "-" + millisecond;

            //Lấy danh sách file Attach
            BAttach            Bobj = new BAttach();
            HttpFileCollection hfc  = Request.Files;
            int    n        = hfc.Count;
            string listFile = ",";

            try
            {
                // Get the HttpFileCollection

                for (int i = 0; i < hfc.Count; i++)
                {
                    HttpPostedFile hpf = hfc[i];
                    if (hpf.ContentLength > 0)
                    {
                        hpf.SaveAs(Server.MapPath("/MyFiles") + "/" + System.IO.Path.GetFileNameWithoutExtension(hpf.FileName).Replace(" ", "_") + str + System.IO.Path.GetExtension(hpf.FileName));
                        OAttach obj = new OAttach();
                        obj.Name        = System.IO.Path.GetFileName(hpf.FileName);
                        obj.Path        = "~/MyFiles" + "/" + System.IO.Path.GetFileNameWithoutExtension(hpf.FileName).Replace(" ", "_") + str + System.IO.Path.GetExtension(hpf.FileName);
                        obj.Description = "";
                        Bobj.Add(obj);
                        listFile += Bobj.GetLast().FirstOrDefault().AttachID.ToString() + ",";
                    }
                }
            }
            catch (Exception ex)
            {
            }


            //Lấy danh sách người thực hiện công việc

            string UserJoin = hdfUsers.Value;

            if (UserJoin == ",")
            {
                UserJoin = "";
            }
            else
            {
                UserJoin = "," + UserJoin;
            }
            //Lấy mức độ ưu tiên
            string Priority = string.Empty;

            if (rdoPrior1.Checked == true)
            {
                Priority = "RAT_QUAN_TRONG";
            }
            else if (rdoPrior2.Checked == true)
            {
                Priority = "QUAN_TRONG";
            }
            else
            {
                Priority = "BINH_THUONG";
            }

            //Lưu công việc mới
            OWork objWork = new OWork();

            objWork.Name         = txtWorkName.Text;
            objWork.Description  = txtDescription.Text;
            objWork.Content      = txtContent.Text;
            objWork.Attachs      = listFile;
            objWork.IDUserCreate = Global.UserInfo.UserID;
            BUser ctl = new BUser();

            //-- Kiểm tra quyền giao việc
            if (ctl.HasPermission(Global.UserInfo.UserID, PermissionCode.WorkAssignment.ToString()) || Global.IsAdmin())
            {
                objWork.IDUserProcess = UserJoin;
            }
            else
            {
                objWork.IDUserProcess = "," + Global.UserInfo.UserName + ",";
            }

            objWork.IDWorkGroup  = int.Parse(ddlWorkGroup.SelectedValue);
            objWork.CreateDate   = CurrentTime;
            objWork.Status       = "CHUA_GIAO";
            objWork.Priority     = Priority;
            objWork.StartProcess = DateTime.Parse(txtStartDate.Text, culture, DateTimeStyles.NoCurrentDateDefault);
            objWork.EndProcess   = DateTime.Parse(txtEndDate.Text, culture, DateTimeStyles.NoCurrentDateDefault);

            BWork BobjWork = new BWork();

            BobjWork.Add(objWork);
            Response.Redirect("WorkAssignment.aspx");
        }
Example #20
0
        protected void btnForward_Click(object sender, EventArgs e)
        {
            int         WorkID  = int.Parse(Request.QueryString["WorkID"].ToString());
            CultureInfo culture = new CultureInfo("fr-FR", true);

            //Upload File
            DateTime CurrentTime = DateTime.Now;
            string   day         = CurrentTime.Day.ToString();
            string   month       = CurrentTime.Month.ToString();
            string   year        = CurrentTime.Year.ToString();
            string   hour        = CurrentTime.Hour.ToString();
            string   minute      = CurrentTime.Minute.ToString();
            string   millisecond = CurrentTime.Millisecond.ToString();
            string   str         = "-" + day + "-" + month + "-" + year + "-" + "-" + hour + "-" + minute + "-" + millisecond;

            //Lấy danh sách file Attach
            BAttach            Bobj = new BAttach();
            HttpFileCollection hfc  = Request.Files;
            int    n        = hfc.Count;
            string listFile = ",";

            try
            {
                // Get the HttpFileCollection

                for (int i = 0; i < hfc.Count; i++)
                {
                    HttpPostedFile hpf = hfc[i];
                    if (hpf.ContentLength > 0)
                    {
                        hpf.SaveAs(Server.MapPath("/MyFiles") + "/" + System.IO.Path.GetFileNameWithoutExtension(hpf.FileName).Replace(" ", "_") + str + System.IO.Path.GetExtension(hpf.FileName));
                        OAttach obj = new OAttach();
                        obj.Name        = System.IO.Path.GetFileName(hpf.FileName);
                        obj.Path        = "~/MyFiles" + "/" + System.IO.Path.GetFileNameWithoutExtension(hpf.FileName).Replace(" ", "_") + str + System.IO.Path.GetExtension(hpf.FileName);
                        obj.Description = "";
                        Bobj.Add(obj);
                        listFile += Bobj.GetLast().FirstOrDefault().AttachID.ToString() + ",";
                    }
                }
            }
            catch (Exception ex)
            {
            }


            //Lấy danh sách người thực hiện công việc

            string UserJoin = hdfUsers.Value;

            if (UserJoin == ",")
            {
                UserJoin = "";
            }
            else
            {
                UserJoin = "," + UserJoin;
            }
            //Lấy mức độ ưu tiên
            string Priority = string.Empty;

            if (rdoPrior1.Checked == true)
            {
                Priority = "RAT_QUAN_TRONG";
            }
            else if (rdoPrior2.Checked == true)
            {
                Priority = "QUAN_TRONG";
            }
            else
            {
                Priority = "BINH_THUONG";
            }

            // Cập nhật công việc
            OWork objWork = new OWork();
            BWork _BWork  = new BWork();

            objWork = _BWork.GetWork(WorkID).First();

            string Name        = txtWorkName.Text;
            string Description = txtDescription.Text;
            string Content     = txtContent.Text;
            string Attachs     = objWork.Attachs;

            if (listFile != ",")
            {
                Attachs = Attachs.Remove(Attachs.Length - 1, 1) + listFile;
            }
            int    IDUserCreate  = objWork.IDUserCreate;
            string IDUserProcess = "";
            //-- Kiểm tra quyền giao việc
            BUser ctl = new BUser();

            if (ctl.HasPermission(Global.UserInfo.UserID, PermissionCode.WorkAssignment.ToString()) || Global.IsAdmin())
            {
                IDUserProcess = UserJoin;
            }
            else
            {
                IDUserProcess = "," + Global.UserInfo.UserName + ",";
            }
            int      IDWorkGroup = int.Parse(ddlWorkGroup.SelectedValue);
            DateTime CreateDate  = objWork.CreateDate;
            string   Status      = "DANG_THUC_HIEN";
            // Priority = Priority;
            DateTime StartProcess = DateTime.Parse(txtStartDate.Text, culture, DateTimeStyles.NoCurrentDateDefault);
            DateTime EndProcess   = DateTime.Parse(txtEndDate.Text, culture, DateTimeStyles.NoCurrentDateDefault);

            BWork BobjWork = new BWork();

            if (BobjWork.Update(WorkID, Name, Description, Content, Attachs, IDUserCreate, IDUserProcess, CreateDate, StartProcess, EndProcess, Status, Priority, IDWorkGroup))
            {
                Response.Redirect("WorkAssignment.aspx");
            }
            else
            {
                RegisterClientScriptBlock("NOTE", "<script>alert('Giao việc không thành công');</script>");
            }
        }