Beispiel #1
0
        private void grvNhanVien_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            try
            {
                GridView View = sender as GridView;

                if (df != null)
                {
                    foreach (DataRow item1 in df.Rows)
                    {
                        if (View.GetRowCellValue(e.RowHandle, colNhanVien).ToString() == item1["FullName"].ToString())
                        {
                            if (View.GetRowCellValue(e.RowHandle, colThoiGian).ToString() == "Dự kiến")
                            {
                                DateTime Tomau  = TextUtils.ToDate(item1["ThoiGianBDDuKien"].ToString());
                                DateTime Tomau1 = TextUtils.ToDate(item1["ThoiGianKTDuKien"].ToString());
                                _paraName[0] = "@NgayBD"; _paraValue[0] = Tomau;
                                _paraName[1] = "@NgayKT"; _paraValue[1] = Tomau1;
                                //DataTable hu = TextUtils.Select("select distinct ThoiGianBDDuKienSP as ThoiGianBDDuKien,ThoiGianKTDuKienSP as ThoiGianKTDuKien,Name from vHangMucCongViec where ThoiGianKTDuKien between " + NgayBD + " and " + NgayKT);
                                DataTable Source2 = ModulesBO.Instance.LoadDataFromSP("sp_ThongKeTHeoNhom1", "Source", _paraName, _paraValue);
                                if (Source2 != null)
                                {
                                    if (Source2.Rows.Count > 0)
                                    {
                                        Tomau1 = Tomau1.AddDays(Source2.Rows.Count);
                                    }
                                }
                                if (TextUtils.DateDiff("d", Tomau1, Tomau) >= 0)
                                {
                                    foreach (GridColumn item in View.Columns)
                                    {
                                        for (int i = 0; i <= TextUtils.DateDiff("d", Tomau1, Tomau); i++)
                                        {
                                            DateTime tBNgay = Tomau.AddDays(i);
                                            if (TextUtils.DateDiff("d", Tomau1, tBNgay) > 0)
                                            {
                                                if (tBNgay.ToString("dd/MM/yyyy") == item.ToolTip)
                                                {
                                                    if (e.Column == item)
                                                    {
                                                        {
                                                            e.DisplayText          = "8";
                                                            e.Appearance.BackColor = Color.Orange;
                                                        }
                                                        break;
                                                    }
                                                }
                                            }
                                            else
                                            if (TextUtils.DateDiff("d", Tomau1, tBNgay) == 0)
                                            {
                                                if (tBNgay.ToString("dd/MM/yyyy") == item.ToolTip)
                                                {
                                                    if (e.Column == item)
                                                    {
                                                        {
                                                            e.DisplayText          = item1["du"].ToString();
                                                            e.Appearance.BackColor = Color.Orange;
                                                        }
                                                        break;
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                return;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                return;

                throw;
            }
            //try
            //{
            //    GridView View = sender as GridView;

            //    if (df != null)
            //    {
            //        foreach (DataRow item1 in df.Rows)
            //        {
            //            if (View.GetRowCellValue(e.RowHandle, colNhanVien).ToString() == item1["FullName"].ToString())
            //            {
            //                if (View.GetRowCellValue(e.RowHandle, colThoiGian).ToString() == "Dự kiến")
            //                {
            //                    DateTime Tomau = TextUtils.ToDate(item1["ThoiGianBDDuKien"].ToString());
            //                    DateTime Tomau1 = TextUtils.ToDate(item1["ThoiGianKTDuKien"].ToString());

            //                    if (TextUtils.DateDiff("d", Tomau1, Tomau) > 0)
            //                    {

            //                        for (int i = 0; i <= TextUtils.DateDiff("d", Tomau1, Tomau); i++)
            //                        {
            //                            DateTime tBNgay = Tomau.AddDays(i);
            //                            if (TextUtils.DateDiff("d", Tomau1, tBNgay) > 0)
            //                            {
            //                                foreach (GridColumn item in View.Columns)
            //                                {

            //                                    if (tBNgay.ToString("dd/MM/yyyy") == item.ToolTip)
            //                                    {
            //                                        if (e.Column == item)
            //                                        {
            //                                                e.Appearance.BackColor = Color.Orange;
            //                                                e.DisplayText = "8";
            //                                                break;
            //                                        }
            //                                    }
            //                                }
            //                            }
            //                            if (TextUtils.DateDiff("d", Tomau1, tBNgay) == 0)
            //                            {
            //                                foreach (GridColumn item in View.Columns)
            //                                {
            //                                    if (tBNgay.ToString("dd/MM/yyyy") == item.ToolTip)
            //                                    {
            //                                        if (e.Column == item)
            //                                        {
            //                                            {
            //                                                e.Appearance.BackColor = Color.Orange;
            //                                                e.DisplayText = item1["du"].ToString();
            //                                            }
            //                                            break;
            //                                        }
            //                                    }
            //                                }
            //                            }
            //                        }
            //                    }
            //                }
            //            }
            //        }
            //    }


            //}
            //catch (Exception)
            //{
            //    return;
            //    throw;
            //}
            //try
            //{
            //    GridView View = sender as GridView;
            //    if (df != null)
            //    {
            //        foreach (GridColumn item in View.Columns)
            //        {
            //            foreach (DataRow item1 in df.Rows)
            //            {
            //                DateTime Tomau = TextUtils.ToDate(item1["ThoiGianBDDuKien"].ToString());
            //                if (Tomau.ToString("dd/MM/yyyy") == item.ToolTip)
            //                {
            //                    if (View.GetRowCellValue(e.RowHandle, colNhanVien).ToString() == item1["FullName"].ToString())
            //                    {
            //                        if (View.GetRowCellValue(e.RowHandle, colThoiGian).ToString() == "Dự kiến")
            //                        {
            //                            if (e.Column == item)
            //                            {
            //                                int tongh = Convert.ToInt32(item1["tongtg"].ToString());
            //                                if (tongh <= 8)
            //                                {
            //                                    e.DisplayText = item1["tongtg"].ToString();
            //                                }
            //                                else
            //                                {
            //                                    int giat = tongh / 8;
            //                                    int thua = tongh % 8;
            //                                    e.DisplayText = tongh.ToString();
            //                                    grvNhanVien.SetFocusedRowCellValue("thu2", thua);
            //                                }
            //                            }
            //                        }
            //                    }
            //                }
            //                else
            //                    continue;
            //            }
            //        }
            //    }

            //}
            //catch (Exception)
            //{
            //    return;
            //    throw;
            //}
        }
Beispiel #2
0
        public void SelectAll(ref DataTable dt, GridControl grd)
        {
            try
            {
                TheoDoiVatTu_BLL.YeuCauVatTu_BLL           obj = new TheoDoiVatTu_BLL.YeuCauVatTu_BLL();
                TheoDoiVatTu_Entities.YeuCauVatTu_Entities p   = new TheoDoiVatTu_Entities.YeuCauVatTu_Entities();
                p.UserID = Global.UserID;
                try
                {
                    dt = TextUtils.Select("select * from vCheckPermission where Code ='frmMainVatTu_ViewAll' and UserID=" + Global.UserID);
                    if (dt.Rows.Count > 0)
                    {
                        dt = obj.SelectAll();
                        //bar1.Visible = false;
                    }
                    else
                    {
                        dt = obj.SelectByID(p);
                    }
                }
                catch (Exception)
                {
                    dt = obj.SelectByID(p);
                }

                if (dt == null)
                {
                    dt = new DataTable();
                    dt.Columns.Add("ID", typeof(int));
                    dt.Columns.Add("TenVatTu", typeof(string));
                    dt.Columns.Add("MaVatTu", typeof(string));
                    dt.Columns.Add("Hang", typeof(string));
                    dt.Columns.Add("MaSP", typeof(string));
                    dt.Columns.Add("TenDuAn", typeof(string));
                    dt.Columns.Add("MaDuAn", typeof(string));
                    dt.Columns.Add("SoLuong", typeof(int));
                    dt.Columns.Add("NgayYeuCau", typeof(DateTime));
                    dt.Columns.Add("NgayVeDuKien", typeof(DateTime));
                    dt.Columns.Add("NgayVeDuKien2", typeof(DateTime));
                    dt.Columns.Add("NgayVeDuKien3", typeof(DateTime));
                    dt.Columns.Add("NgayThucTe", typeof(DateTime));
                    dt.Columns.Add("ThoiGianDatHangTHucTe", typeof(string));
                    dt.Columns.Add("NguyenNhanCham", typeof(string));
                    dt.Columns.Add("GhiChu", typeof(string));
                    dt.Columns.Add("UserID", typeof(string));
                }
                dt.Columns.Add("ThoiGianDatHangThucTe", typeof(string));
                dt.Columns.Add("STT", typeof(string));
                dt.Columns.Add("Status", typeof(int));
                TheoDoiVatTu_BLL.Users_BLL pl = new TheoDoiVatTu_BLL.Users_BLL();
                colNguoiYeuCau.DataSource    = pl.SelectAll();
                colNguoiYeuCau.DisplayMember = "FullName";
                colNguoiYeuCau.ValueMember   = "ID";
                colNguoiYeuCau.NullText      = "Tên nhân viên";
                ChuaXong = 0; Xong = 0; GanXong = 0;

                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        DataRow row = dt.Rows[i];
                        if (row["NgayYeuCau"].ToString().Trim() != "")
                        {
                            if (row["NgayThucTe"].ToString().Trim() != "")
                            {
                                DateTime ngaymuon = Convert.ToDateTime(row["NgayYeuCau"]);
                                DateTime ngaytra  = Convert.ToDateTime(row["NgayThucTe"]);
                                TimeSpan tim      = ngaytra - ngaymuon;
                                row["ThoiGianDatHangThucTe"] = tim.Days.ToString();
                            }
                        }
                        if (row["NgayThucTe"].ToString().Trim() == "")
                        {
                            row["Status"] = 0;
                            ChuaXong++;
                        }
                        if (row["NgayThucTe"].ToString().Trim() != "")
                        {
                            TimeSpan tim = new TimeSpan();
                            int      k   = 0;
                            if (row["NgayVeDuKien3"].ToString().Trim() != "")
                            {
                                DateTime ngaymuon = Convert.ToDateTime(row["NgayVeDuKien3"]);
                                DateTime ngaytra  = Convert.ToDateTime(row["NgayThucTe"]);
                                tim = ngaytra - ngaymuon;
                                k   = TextUtils.DateDiff("d", ngaytra, ngaymuon);
                            }
                            else
                            if (row["NgayVeDuKien2"].ToString().Trim() != "")
                            {
                                DateTime ngaymuon = Convert.ToDateTime(row["NgayVeDuKien2"]);
                                DateTime ngaytra  = Convert.ToDateTime(row["NgayThucTe"]);
                                tim = ngaytra - (ngaymuon); k = TextUtils.DateDiff("d", ngaytra, ngaymuon);
                            }
                            else
                            if (row["NgayVeDuKien"].ToString().Trim() != "")
                            {
                                DateTime ngaymuon = Convert.ToDateTime(row["NgayVeDuKien"]);
                                DateTime ngaytra  = Convert.ToDateTime(row["NgayThucTe"]);
                                tim = ngaytra - ngaymuon; k = TextUtils.DateDiff("d", ngaytra, ngaymuon);
                            }
                            {
                                if (tim.Days > 0)
                                {
                                    if (row["NguyenNhanCham"].ToString() != "")
                                    {
                                        row["Status"] = 2;
                                        Xong++;
                                    }
                                    else
                                    {
                                        row["Status"] = 1;
                                        ChuaXong++;
                                        GanXong++;
                                    }
                                }
                                if (tim.Days <= 0)
                                {
                                    row["Status"] = 3;
                                    Xong++;
                                }
                            }
                        }
                    }
                }
                DataView dv = dt.DefaultView;

                dv.Sort = "Status ASC";

                dt = dv.ToTable();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow row = dt.Rows[i];
                    row["STT"] = i + 1;
                }
                grd.DataSource = dt;
                grvData.BestFitColumns();
                grvData.Columns["Status"].SortOrder = ColumnSortOrder.Ascending;
                toolStripLabel1.Text = "Số vật tư chưa hoàn thành " + ChuaXong;
                View_popup();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #3
0
        private void bandedGridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            try
            {
                GridView View = sender as GridView;

                if (Source != null)
                {
                    foreach (DataRow item1 in Source.Rows)
                    {
                        if (View.GetRowCellValue(e.RowHandle, colNhom).ToString() == item1["Name"].ToString())
                        {
                            DateTime Tomau  = TextUtils.ToDate(item1["ThoiGianBDDuKien"].ToString());
                            DateTime Tomau1 = TextUtils.ToDate(item1["ThoiGianKTDuKien"].ToString());
                            _paraName[0] = "@NgayBD"; _paraValue[0] = Tomau;
                            _paraName[1] = "@NgayKT"; _paraValue[1] = Tomau1;
                            //DataTable hu = TextUtils.Select("select distinct ThoiGianBDDuKienSP as ThoiGianBDDuKien,ThoiGianKTDuKienSP as ThoiGianKTDuKien,Name from vHangMucCongViec where ThoiGianKTDuKien between " + NgayBD + " and " + NgayKT);
                            DataTable Source2 = ModulesBO.Instance.LoadDataFromSP("sp_ThongKeTHeoNhom1", "Source", _paraName, _paraValue);
                            if (Source2 != null)
                            {
                                if (Source2.Rows.Count > 0)
                                {
                                    Tomau1 = Tomau1.AddDays(Source2.Rows.Count);
                                }
                            }
                            if (TextUtils.DateDiff("d", Tomau1, Tomau) >= 0)
                            {
                                foreach (GridColumn item in View.Columns)
                                {
                                    for (int i = 0; i <= TextUtils.DateDiff("d", Tomau1, Tomau); i++)
                                    {
                                        DateTime tBNgay = Tomau.AddDays(i);
                                        if (TextUtils.DateDiff("d", Tomau1, tBNgay) >= 0)
                                        {
                                            if (tBNgay.ToString("dd/MM/yyyy") == item.ToolTip)
                                            {
                                                if (e.Column == item)
                                                {
                                                    if (e.Appearance.BackColor == Color.Orange)
                                                    {
                                                        e.Appearance.BackColor = Color.Red;
                                                    }
                                                    else
                                                    {
                                                        e.Appearance.BackColor = Color.Orange;
                                                    }
                                                    break;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                return;

                throw;
            }
        }
Beispiel #4
0
        private void grvData_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            try
            {
                GridView View = sender as GridView;
                if (e.RowHandle >= 0)
                {
                    if (View.GetRowCellValue(e.RowHandle, colThoiGianBDDuKien).ToString().Trim() != "")
                    {
                        if (View.GetRowCellValue(e.RowHandle, colThoiGianKTDuKien).ToString().Trim() != "")
                        {
                            DateTime Tomau  = TextUtils.ToDate(View.GetRowCellValue(e.RowHandle, colThoiGianBDDuKien).ToString().Trim());
                            DateTime Tomau1 = TextUtils.ToDate(View.GetRowCellValue(e.RowHandle, colThoiGianKTDuKien).ToString().Trim());

                            if (TextUtils.DateDiff("d", Tomau1, Tomau) < 0)
                            {
                                return;
                            }
                            else
                            if (TextUtils.DateDiff("d", Tomau1, Tomau) > 0)
                            {
                                foreach (GridColumn item in View.Columns)
                                {
                                    for (int i = 0; i < 55; i++)
                                    {
                                        DateTime tBNgay = Tomau.AddDays(i);
                                        if (TextUtils.DateDiff("d", Tomau1, tBNgay) > 0)
                                        {
                                            if (tBNgay.ToString("dd/MM/yyyy") == item.ToolTip)
                                            {
                                                if (e.Column == item)
                                                {
                                                    e.Appearance.BackColor = Color.Orange;
                                                    break;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                            foreach (GridColumn item in View.Columns)
                            {
                                if (Tomau1.ToString("dd/MM/yyyy") == item.ToolTip)
                                {
                                    if (e.Column == item)
                                    {
                                        e.Appearance.BackColor = Color.Orange;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                return;

                throw;
            }
        }