Example #1
0
        public void Save(ref DataTable dt)
        {
            if (searchLookUpEdit1.EditValue == null)
            {
                XtraMessageBox.Show("Xin mời bạn chọn dự án");
                return;
            }
            grvData.FocusedRowHandle = -1;
            if (kt == false)
            {
                return;
            }
            DataTable dtRemine;

            dtRemine = grdData.DataSource as DataTable;
            {
                for (int i = 0; i < dtRemine.Rows.Count; i++)
                {
                    SanPhamDAModel model = new SanPhamDAModel();
                    model.ProjectsID       = searchLookUpEdit1.EditValue.ToString();
                    model.TenTheoHopDong   = dtRemine.Rows[i]["TenTheoHopDong"].ToString();
                    model.MaTheoHopDong    = dtRemine.Rows[i]["MaTheoHopDong"].ToString();
                    model.TenTheoThietKe   = dtRemine.Rows[i]["TenTheoThietKe"].ToString();
                    model.MaTheoThietKe    = dtRemine.Rows[i]["MaTheoThietKe"].ToString();
                    model.ThoiGianThietKe  = TextUtils.ToInt(dtRemine.Rows[i]["ThoiGianThietKe"].ToString());
                    model.ThoiGianBDDuKien = TextUtils.ToDate(dtRemine.Rows[i]["ThoiGianBDDuKien"].ToString());
                    model.ThoiGianBDThucTe = (dtRemine.Rows[i]["ThoiGianBDThucTe"].ToString());
                    model.ThoiGianKTDuKien = TextUtils.ToDate(dtRemine.Rows[i]["ThoiGianKTDuKien"].ToString());
                    model.ThoiGianKTThucTe = (dtRemine.Rows[i]["ThoiGianKTThucTe"].ToString());
                    model.TinhTrang        = dtRemine.Rows[i]["TinhTrang"].ToString();;
                    model.NhomPhuTrach     = dtRemine.Rows[i]["NhomPhuTrach"].ToString();;
                    model.MucDoUuTien      = dtRemine.Rows[i]["MucDoUuTien"].ToString();;
                    model.LoaiCongViec     = dtRemine.Rows[i]["LoaiCongViec"].ToString();;
                    if (dtRemine.Rows[i][colID.FieldName] == DBNull.Value) //add new)
                    {
                        //if (XtraMessageBox.Show("Dữ liệu đã bị thay đổi\nBạn có muốn lưu vào cơ sở dữ liệu không?","Xác nhận",MessageBoxButtons.YesNo,MessageBoxIcon.Question)==DialogResult.Yes)
                        {
                            SanPhamDABO.Instance.Insert(model);
                        }
                        {
                        }
                    }
                    else
                    {
                        //if (XtraMessageBox.Show("Dữ liệu đã bị thay đổi\nBạn có muốn lưu vào cơ sở dữ liệu không?", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            model.ID = Convert.ToInt32(dtRemine.Rows[i]["ID"].ToString());
                            SanPhamDABO.Instance.Update(model);
                        }
                        //XtraMessageBox.Show("U thành công!", "Thông báo");
                    }
                }
                XtraMessageBox.Show("Xử lý thành công!", "Thông báo");
            }
        }
Example #2
0
 protected SanPhamDAFacade(SanPhamDAModel model) : base(model)
 {
 }
Example #3
0
        private void grvData_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            GridView view = sender as GridView;

            try
            {
                kt = true;
                #region check vailidate
                //string gg=Convert.ToDateTime(view.GetRowCellValue(e.RowHandle, colThoiGianBDDuKien)).ToString("yyyy/MM/dd");
                //if (SanPhamDABO.Instance.CheckExist("ThoiGianBDDuKien",gg))
                //{
                //    e.Valid = false;
                //    return;
                //}else
                //{

                //}
                if (view.GetRowCellValue(e.RowHandle, colTenTheoHopDong).ToString() == string.Empty)
                {
                    e.Valid = false; kt = false;
                    return;
                }
                else
                if (view.GetRowCellValue(e.RowHandle, colMaTheoThietKe).ToString() == string.Empty)
                {
                    e.Valid = false; kt = false;
                    return;
                }
                else
                if (view.GetRowCellValue(e.RowHandle, colThoiGianThietKe).ToString() == string.Empty)
                {
                    kt = false; e.Valid = false;
                    return;
                }
                else
                if (view.GetRowCellValue(e.RowHandle, colThoiGianBDDuKien).ToString() == string.Empty)
                {
                    kt = false; e.Valid = false;
                    return;
                }
                else
                if (view.GetRowCellValue(e.RowHandle, colNhomPhuTrach).ToString() == string.Empty)
                {
                    kt = false; e.Valid = false;
                    return;
                }
                else
                if (view.GetRowCellValue(e.RowHandle, colMucDoUuTien).ToString() == string.Empty)
                {
                    kt = false; e.Valid = false;
                    return;
                }
                else
                if (view.GetRowCellValue(e.RowHandle, colLoaiCongViec).ToString() == string.Empty)
                {
                    kt = false; e.Valid = false;
                    return;
                }

                int l  = Convert.ToInt32(view.GetRowCellValue(e.RowHandle, colThoiGianThietKe));
                int k  = l / 8;
                int lp = l % 8;
                if (lp == 0)
                {
                    k--;
                }
                if (view.GetRowCellValue(e.RowHandle, colThoiGianBDDuKien).ToString() != string.Empty)
                {
                    view.SetRowCellValue(e.RowHandle, colThoiGianKTDuKien, Convert.ToDateTime(view.GetRowCellValue(e.RowHandle, colThoiGianBDDuKien)).AddDays(k));
                }
                #endregion
                SanPhamDAModel model = new SanPhamDAModel();
                model.ProjectsID       = searchLookUpEdit1.EditValue.ToString();
                model.TenTheoHopDong   = view.GetRowCellValue(e.RowHandle, colTenTheoHopDong).ToString();                     //dtRemine.Rows[i]["TenTheoHopDong"].ToString();
                model.MaTheoHopDong    = view.GetRowCellValue(e.RowHandle, colMaTheoHopDong).ToString();                      //dtRemine.Rows[i]["MaTheoHopDong"].ToString();
                model.TenTheoThietKe   = view.GetRowCellValue(e.RowHandle, colTenTheoThietKe).ToString();                     //dtRemine.Rows[i]["TenTheoThietKe"].ToString();
                model.MaTheoThietKe    = view.GetRowCellValue(e.RowHandle, colMaTheoThietKe).ToString();                      //dtRemine.Rows[i]["MaTheoThietKe"].ToString();
                model.ThoiGianThietKe  = TextUtils.ToInt(view.GetRowCellValue(e.RowHandle, colThoiGianThietKe).ToString());   //dtRemine.Rows[i]["ThoiGianThietKe"].ToString());
                model.ThoiGianBDDuKien = TextUtils.ToDate(view.GetRowCellValue(e.RowHandle, colThoiGianBDDuKien).ToString()); //dtRemine.Rows[i]["ThoiGianBDDuKien"].ToString());
                model.ThoiGianBDThucTe = view.GetRowCellValue(e.RowHandle, colThoiGianBDThucTe).ToString();                   //(dtRemine.Rows[i]["ThoiGianBDThucTe"].ToString());
                model.ThoiGianKTDuKien = TextUtils.ToDate(view.GetRowCellValue(e.RowHandle, colThoiGianKTDuKien).ToString()); //dtRemine.Rows[i]["ThoiGianKTDuKien"].ToString());
                model.ThoiGianKTThucTe = view.GetRowCellValue(e.RowHandle, colThoiGianKTThucTe).ToString();                   //(dtRemine.Rows[i]["ThoiGianKTThucTe"].ToString());
                model.TinhTrang        = view.GetRowCellValue(e.RowHandle, colTinhTrang).ToString();                          //dtRemine.Rows[i]["TinhTrang"].ToString(); ;
                model.NhomPhuTrach     = view.GetRowCellValue(e.RowHandle, colNhomPhuTrach).ToString();                       //dtRemine.Rows[i]["NhomPhuTrach"].ToString(); ;
                model.MucDoUuTien      = view.GetRowCellValue(e.RowHandle, colMucDoUuTien).ToString();                        //dtRemine.Rows[i]["MucDoUuTien"].ToString(); ;
                model.LoaiCongViec     = view.GetRowCellValue(e.RowHandle, colLoaiCongViec).ToString();                       //dtRemine.Rows[i]["LoaiCongViec"].ToString(); ;
                if (view.GetRowCellValue(e.RowHandle, colID) == DBNull.Value)                                                 //add new)
                {
                    if (XtraMessageBox.Show("Dữ liệu đã bị thay đổi\nBạn có muốn lưu vào cơ sở dữ liệu không?", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        SanPhamDABO.Instance.Insert(model);
                    }
                    else
                    {
                        e.Valid = true;
                    }
                }
                else
                {
                    if (XtraMessageBox.Show("Dữ liệu đã bị thay đổi\nBạn có muốn lưu vào cơ sở dữ liệu không?", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        model.ID = Convert.ToInt32(view.GetRowCellValue(e.RowHandle, colID).ToString());
                        SanPhamDABO.Instance.Update(model);
                    }
                    else
                    {
                        e.Valid = true;
                    }
                }
                HienThi(); bandedGridView1.FocusedRowHandle = -1; bandedGridView1.FocusedRowHandle = 0;
            }
            catch (Exception)
            {
                throw;
            }
        }