Ejemplo n.º 1
0
 private void btXoaChiPhi_Click(object sender, EventArgs e)
 {
     if (dgvChiChi.Rows.Count < 1)
     {
         MessageBox.Show("Không có dữ liệu để xóa", "Lỗi: Không có dữ liệu để để xóa!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         tx_TT_GiaCP.Text    = "";
         tx_TT_GhiChuCP.Text = "";
         return;
     }
     if (dgvChiChi.SelectedRows.Count > 0)
     {
         if (listChiPhi.Count > 0 && dgvChiChi.CurrentCell.RowIndex <= (listChiPhi.Count - 1))
         {
             ChiPhi temp = listChiPhi[dgvChiChi.CurrentCell.RowIndex];
             temp.Delete();
             listChiPhi.Remove(temp);
             LoadChiPhi();
         }
         else
         {
             MessageBox.Show("Không có dữ liệu để xóa", "Lỗi: Không có dữ liệu để để xóa!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
     }
 }
Ejemplo n.º 2
0
        private void btHuyCP_Click(object sender, EventArgs e)
        {
            DisableEditChiphi();
            ChiPhi temp = listChiPhi[dgvChiChi.CurrentCell.RowIndex];

            tx_TT_GiaCP.Text           = temp.GiaTien.ToString();
            cb_TT_LoaiCP.SelectedValue = temp.LoaiChiPhi;
            tx_TT_GhiChuCP.Text        = temp.GhiChu;
        }
Ejemplo n.º 3
0
        static public void Del(int intChiPhiID)
        {
            dbControl = new QlShop();
            ChiPhi DelItem = dbControl.ChiPhis.SingleOrDefault(p => p.ChiPhiID == intChiPhiID);

            if (DelItem != null)
            {
                dbControl.ChiPhis.Remove(DelItem);
                dbControl.SaveChanges();
            }
        }
Ejemplo n.º 4
0
 public static ChiPhiModel Map(ChiPhi bl)
 {
     return new ChiPhiModel()
     {
         OnID = bl.OnID,
         SoTien = bl.SoTien,
         NguoiChi = bl.NguoiChi,
         NoiDung = bl.NoiDung,
         NgayChi = bl.NgayChi,
         LoaiChi = bl.LoaiChi == 0 ? string.Empty : EnumHelper.GetEnumDescription((EnumLoaiChi)bl.LoaiChi)
     };
 }
Ejemplo n.º 5
0
 public static bool AddChiPhi(ChiPhi cp)
 {
     try
     {
         using (var _context = new QuanLyDuAnEntities1())
         {
             _context.ChiPhis.Add(cp);
             _context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 6
0
 static public int  Add(ChiPhi item)
 {
     using (TransactionScope Tscope = new TransactionScope())
     {
         dbControl         = new QlShop();
         item.LastUpdate   = DateTime.Now;
         item.CreateDate   = DateTime.Now;
         item.NguoiDungID  = Utility.NguoiSuDung.NguoiDungID;
         item.TenNguoiDung = Utility.NguoiSuDung.TenNguoiDung;
         //dbControl.ChiPhi.InsertOnSubmit(item);
         dbControl.ChiPhis.Add(item);
         dbControl.SaveChanges();
         QuyTienMatController.XuatQuyTienMat(item.ChiPhiID.ToString(), item.NgayChi, item.SoTien, "CP", "TT chi phí");
         Tscope.Complete();
     }
     return(item.ChiPhiID);
 }
Ejemplo n.º 7
0
 private void dgvChiChi_SelectionChanged(object sender, EventArgs e)
 {
     if (dgvChiChi.Rows.Count < 1)
     {
         return;
     }
     if (dgvChiChi.SelectedRows.Count > 0)
     {
         if (listChiPhi.Count > 0 && dgvChiChi.CurrentCell.RowIndex <= (listChiPhi.Count - 1))
         {
             ChiPhi temp = listChiPhi[dgvChiChi.CurrentCell.RowIndex];
             tx_TT_GiaCP.Text           = temp.GiaTien.ToString();
             cb_TT_LoaiCP.SelectedValue = temp.LoaiChiPhi;
             tx_TT_GhiChuCP.Text        = temp.GhiChu;
         }
     }
 }
Ejemplo n.º 8
0
 public static bool updateChiPhi(ChiPhi cp)
 {
     try
     {
         using (var _context = new QuanLyDuAnEntities1())
         {
             //cv.ChiPhi = getChiPhiCV(cv.MaCongViec);
             _context.ChiPhis.AddOrUpdate(cp);
             _context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 9
0
        private void btLuuCP_Click(object sender, EventArgs e)
        {
            ChiPhi curChiPhi = listChiPhi[dgvChiChi.CurrentCell.RowIndex];
            ChiPhi temp      = new ChiPhi()
            {
                Id         = curChiPhi.Id,
                LoaiChiPhi = int.Parse(cb_TT_LoaiCP.SelectedValue.ToString()),
                MaDoan     = curDoanDL.Id,
                GiaTien    = decimal.Parse(tx_TT_GiaCP.Text),
                GhiChu     = tx_TT_GhiChuCP.Text,
                updated    = true
            };

            temp.Save();
            listChiPhi = curDoanDL.GetChiPhiDoan();
            DisableEditChiphi();
            LoadChiPhi();
        }
Ejemplo n.º 10
0
        private void btThemChiPhi_Click(object sender, EventArgs e)
        {
            if (tx_Them_GiaTien.Text.Trim() == "")
            {
                MessageBox.Show("Mục thêm giá rỗng", "Lỗi: Không được để mục thêm giá RỖNG!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            ChiPhi chiphi = new ChiPhi()
            {
                Id = -1, LoaiChiPhi = int.Parse(cb_Them_LoaiCP.SelectedValue.ToString()), MaDoan = curDoanDL.Id, GhiChu = tx_Them_ghichu.Text, GiaTien = decimal.Parse(tx_Them_GiaTien.Text.ToString())
            };

            chiphi.Save();
            listChiPhi.Add(chiphi);
            tx_Them_GiaTien.Text = "";
            tx_Them_ghichu.Text  = "";

            LoadChiPhi();
        }
Ejemplo n.º 11
0
        private void btnThemChiPhi_Click(object sender, EventArgs e)
        {
            if (this.txtMaCongViec.Text.Trim().Length <= 0)
            {
                this.errorProvider1.SetError(this.txtMaCongViec, "nhap ten ma cong viec");
                return;
            }
            else
            {
                this.errorProvider1.Clear();
            }
            if (this.txtCongViec.Text.Trim().Length <= 0)
            {
                this.errorProvider1.SetError(this.txtCongViec, "nhap ten cong viec");
                return;
            }
            else
            {
                this.errorProvider1.Clear();
            }
            if (this.txtChiPhi.Text.Trim().Length <= 0)
            {
                this.errorProvider1.SetError(this.txtChiPhi, "nhap chi phi");
                return;
            }
            else
            {
                this.errorProvider1.Clear();
            }
            ChiPhi cp = new ChiPhi();

            cp.MaCongViecChiTieu = txtMaCongViec.Text.Trim();
            cp.CongViecChiTieu   = txtCongViec.Text.Trim();
            cp.ChiPhiCongViec    = int.Parse(txtChiPhi.Text.Trim());
            cp.ThucHien          = dateTimeNgayThucHien.Value;

            ChiPhiControllers.AddChiPhi(cp);
            BindingSource source = new BindingSource();

            source.DataSource             = ChiPhiControllers.getListChiPhifromDB();
            this.dataGridView1.DataSource = source;
        }
Ejemplo n.º 12
0
        public void save()
        {
            ChiPhi item = new ChiPhi();

            item.TenChiPhi     = txtTenChiPhi.Text.Trim();
            item.NgayChi       = dateEditNgayChi.DateTime;
            item.LoaiChiPhiID  = Convert.ToInt32(lookupLoaiChiPhi.EditValue.ToString());
            item.TenLoaiChiPhi = lookupLoaiChiPhi.Text;
            item.SoTien        = txtSoTien.Value;
            item.GhiChu        = txtGhiChu.Text.Trim();
            if ((frmMode.ToUpper().Equals("EDIT")) && (editItem != null))
            {
                item.ChiPhiID = editItem.ChiPhiID;
                ChiPhiController.Edit(item);
                editItem = null;
            }
            else
            {
                ChiPhiController.Add(item);
            }
        }
Ejemplo n.º 13
0
        static public void Edit(ChiPhi item)
        {
            dbControl = new QlShop();
            ChiPhi oItem = new ChiPhi();

            oItem = dbControl.ChiPhis.SingleOrDefault(p => p.ChiPhiID == item.ChiPhiID);
            if (oItem != null)
            {
                oItem.TenChiPhi     = item.TenChiPhi;
                oItem.NgayChi       = item.NgayChi;
                oItem.LoaiChiPhiID  = item.LoaiChiPhiID;
                oItem.TenLoaiChiPhi = item.TenLoaiChiPhi;
                oItem.SoTien        = item.SoTien;
                oItem.GhiChu        = item.GhiChu;
                //--thông tin bao mật
                oItem.NguoiDungID  = Utility.NguoiSuDung.NguoiDungID;
                oItem.TenNguoiDung = Utility.NguoiSuDung.TenNguoiDung;
                oItem.LastUpdate   = DateTime.Now;
                dbControl.SaveChanges();
            }
            dbControl.Dispose();
        }
Ejemplo n.º 14
0
        // insert chi phí
        public bool insertChiPhi(ChiPhi cp)
        {
            string        query   = "insert into ChiPhi (MaDoan,TenChiPhi,SoTien,GhiChu) values(@MaDoan,@TenCP,@SoTien,@GhiChu)";
            SqlConnection connect = conn.getConnect();

            try
            {
                cmd = new SqlCommand(query, connect);
                connect.Open();
                cmd.Parameters.Add("@MaDoan", SqlDbType.Int).Value      = cp.MaDoan;
                cmd.Parameters.Add("@TenCP", SqlDbType.NVarChar).Value  = cp.tenCP;
                cmd.Parameters.Add("@SoTien", SqlDbType.Float).Value    = cp.sotien;
                cmd.Parameters.Add("@GhiChu", SqlDbType.NVarChar).Value = cp.ghiChu;
                cmd.ExecuteNonQuery();
                connect.Close();
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 15
0
        public async Task <string> Create(CreatedChiPhiRequest request)
        {
            var ChiPhi = from CP in _context.ChiPhis
                         select CP;

            string SoLuongChiPhi = ChiPhi.Count().ToString();

            do
            {
                SoLuongChiPhi = (Convert.ToInt32(SoLuongChiPhi) + 1).ToString();
            }while (_context.CapBacs.Find("CP" + SoLuongChiPhi) != null);
            var chiphi = new ChiPhi()
            {
                MaChiPhi  = "CP" + SoLuongChiPhi,
                TenChiPhi = request.TenChiPhi,
                MoTa      = request.MoTa
            };

            _context.ChiPhis.Add(chiphi);
            await _context.SaveChangesAsync();

            return(chiphi.MaChiPhi);
        }
        private void btnSuaCongViec_Click(object sender, EventArgs e)
        {
            if (this.txtMaCongViecNhanVien.Text.Trim().Length <= 0 || this.txtMaNhanVien.Text.Trim().Length <= 0 || this.dateTimeDuKienHoanThanhCVNV.Value > DateTime.Now || this.dateTimeNgayBatDauCVNV.Value > DateTime.Now || this.dateTimeNgayKetThucCVNV.Value > DateTime.Now)
            {
                if (this.txtMaCongViecNhanVien.Text.Trim().Length <= 0)
                {
                    this.errorProvider1.SetError(this.txtMaCongViecNhanVien, "Ma cong viec khong duoc trong");
                    return;
                }
                else if (this.txtMaNhanVien.Text.Trim().Length <= 0)
                {
                    this.errorProvider1.SetError(this.txtMaNhanVien, "Ma nhan vien khong duoc de trong");
                    return;
                }
                this.errorProvider1.Clear();
                if (this.txtTenCongViecNhanVien.Text.Trim().Length <= 0)
                {
                    this.errorProvider1.SetError(this.txtTenCongViecNhanVien, "nhap ten cong viec");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
                if (this.txtMoTaCongViecNhanVien.Text.Trim().Length <= 0)
                {
                    this.errorProvider1.SetError(this.txtMoTaCongViecNhanVien, "nhap mo ta cong viec");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
                if (this.txtLuongCongViec.Text.Trim().Length <= 0)
                {
                    this.errorProvider1.SetError(this.txtLuongCongViec, "nhap luong cong viec");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
                if (this.dateTimeNgayBatDauCVNV.Value <= DateTime.Now)
                {
                    this.errorProvider1.SetError(this.dateTimeNgayBatDauCVNV, "nhap ngay bat dau");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
                if (this.dateTimeDuKienHoanThanhCVNV.Value <= DateTime.Now)
                {
                    this.errorProvider1.SetError(this.dateTimeDuKienHoanThanhCVNV, "nhap ngay du kien hoan thanh");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
            }
            CongViecNhanVien cv = new CongViecNhanVien();

            cv.MaCongViecNhanVien = txtMaCongViecNhanVien.Text.Trim();
            cv.TenCongViec        = txtTenCongViecNhanVien.Text.Trim();
            cv.MaNhanVienPhuTrach = txtMaNhanVien.Text.Trim();
            cv.MoTa            = txtMoTaCongViecNhanVien.Text.Trim();
            cv.LuongCongViec   = int.Parse(txtLuongCongViec.Text.Trim());
            cv.TaiLieu         = txtTaiLieu.Text.Trim();
            cv.NgayBatDau      = DateTime.Parse(dateTimeNgayBatDauCVNV.Value.ToString());
            cv.DuKienHoanThanh = DateTime.Parse(dateTimeDuKienHoanThanhCVNV.Value.ToString());
            cv.NgayHoanThanh   = DateTime.Parse(dateTimeNgayKetThucCVNV.Value.ToString());
            cv.TienDo          = bool.Parse(txtTienDoCongViecNhanVien.Text);

            ChiPhi cp = new ChiPhi();

            cp.ChiPhiCongViec    = cv.LuongCongViec;
            cp.MaCongViecChiTieu = cv.MaCongViecNhanVien;
            cp.CongViecChiTieu   = cv.TenCongViec;
            cp.ThucHien          = DateTime.Parse(dateTimeNgayKetThucCVNV.Value.ToString());
            ChiPhiControllers.updateChiPhi(cp);

            CongViecNhanVienControllers.updateCongViecNhanVien(cv);
            BindingSource source = new BindingSource();

            source.DataSource = CongViecNhanVienControllers.getListCongViecNhanVienfromDB();
            this.dataGridViewCongViecDangThucHien.DataSource = source;
        }
Ejemplo n.º 17
0
 private void btLuu_Click(object sender, EventArgs e)
 {
     //update đoàn
     if (Validate() == true)
     {
         Doan d = new Doan();
         d.MaDoan  = int.Parse(cbbMaDoan.Text);
         d.MaTour  = int.Parse(cbbMaTour.Text);
         d.TenDoan = tbTenDoan.Text;
         d.GioDi   = dtGioDi.Text;
         d.GioVe   = dtGioVe.Text;
         if (doan.UpdateDoan(d))
         {
             MessageBox.Show("Sửa đoàn thành công");
         }
         else
         {
             MessageBox.Show("Sửa đoàn thất bại");
         }
         try
         {
             int maDoan = int.Parse(cbbMaDoan.Text);
             //xóa nhân viên theo đoàn
             int flag = 0;
             if (doan.XoaNVTheoDoan(maDoan))
             {
                 Console.WriteLine("Xóa nhân viên theo đoàn thành công");
                 for (int i = 0; i < dgvNV.RowCount - 1; i++)
                 {
                     int maNV      = int.Parse(dgvNV.Rows[i].Cells[0].Value.ToString());
                     int maNhiemVu = int.Parse(dgvNV.Rows[i].Cells[2].Value.ToString());
                     if (doan.insertNVTheoDoan(maNV, maDoan, maNhiemVu))
                     {
                         flag = 0;
                     }
                     else
                     {
                         flag = 1;
                         break;
                     }
                 }
                 if (flag == 0)
                 {
                     MessageBox.Show("Sửa danh sách nhân viên theo đoàn thành công");
                 }
             }
             // xóa chi tiết đoàn
             int flag1 = 0;
             if (doan.XoaChiTietDoan(maDoan))
             {
                 Console.WriteLine("Xóa chi tiết đoàn thành công");
                 for (int vt = 0; vt < dgvKH.RowCount - 1; vt++)
                 {
                     int maKH = int.Parse(dgvKH.Rows[vt].Cells[0].Value.ToString());
                     if (doan.insertCTDoan(maKH, maDoan))
                     {
                         flag1 = 0;
                     }
                     else
                     {
                         flag1 = 1;
                         break;
                     }
                 }
                 if (flag1 == 0)
                 {
                     MessageBox.Show("Sửa danh sách chi tiết đoàn thành công");
                 }
             }//if
              //xóa chi phí đoàn
             int flag2 = 0;
             if (doan.XoaChiPhiDoan(maDoan))
             {
                 Console.WriteLine("Xóa danh sách chi phí đoàn thành công");
                 for (int r = 0; r < dgvChiPhi.RowCount - 1; r++)
                 {
                     ChiPhi p = new ChiPhi();
                     p.tenCP  = dgvChiPhi.Rows[r].Cells[0].Value.ToString();
                     p.sotien = float.Parse(dgvChiPhi.Rows[r].Cells[1].Value.ToString());
                     p.ghiChu = dgvChiPhi.Rows[r].Cells[2].Value.ToString();
                     p.MaDoan = int.Parse(cbbMaDoan.Text);
                     if (doan.insertChiPhi(p))
                     {
                         flag2 = 0;
                     }
                     else
                     {
                         flag2 = 1;
                         break;
                     }
                 }
                 if (flag2 == 0)
                 {
                     MessageBox.Show("Sửa danh sách chi phí của đoàn thành công");
                 }
             }
             else
             {
                 Console.WriteLine("Xóa danh sách chi phí thất bại");
             }
         }
         catch (Exception) { }
     }
     else
     {
         MessageBox.Show("Vui lòng nhập tên đoàn, thêm khách hàng, và nhân viên cho đoàn");
     }
 }
Ejemplo n.º 18
0
 public bool insertChiPhi(ChiPhi cp)
 {
     return(doan.insertChiPhi(cp));
 }
Ejemplo n.º 19
0
        private void ThemDoan1()
        {
            int madoan = int.Parse(tbMaDoan.Text);
            // Thêm đoàn
            Doan d = new Doan();

            //   d.MaDoan = madoan;
            d.MaTour  = int.Parse(cbbMaTour.Text);
            d.TenDoan = tbTenDoan.Text;
            d.GioDi   = dtGioDi.Text;
            d.GioVe   = dtGioVe.Text;
            try
            {
                if (doan.insertDoan(d))
                {
                    MessageBox.Show("thêm đoàn thành công");
                }
                else
                {
                    MessageBox.Show("thêm đoàn thất bại");
                }
            }
            catch (Exception) { }

            // Thêm chi phí
            int flag = 0;

            for (int row = 0; row < dgvChiPhi.RowCount - 1; row++)
            {
                ChiPhi cp = new ChiPhi();
                cp.MaDoan = int.Parse(tbMaDoan.Text);
                cp.tenCP  = dgvChiPhi.Rows[row].Cells[0].Value.ToString();
                cp.sotien = float.Parse(dgvChiPhi.Rows[row].Cells[1].Value.ToString());
                cp.ghiChu = dgvChiPhi.Rows[row].Cells[2].Value.ToString();
                try
                {
                    if (doan.insertChiPhi(cp))
                    {
                        flag = 0;
                    }
                    else
                    {
                        flag = 1;
                        MessageBox.Show("Thêm chi phí đoàn thất bại");
                        break;
                    }
                }
                catch (Exception) { }
            }
            if (flag == 0)
            {
                MessageBox.Show("thêm chi phí đoàn thành công");
            }
            // Thêm nhân viên theo đoàn
            int flag2 = 0;

            for (int vt = 0; vt < dgvNV.RowCount - 1; vt++)
            {
                int nhiemVu = int.Parse(dgvNV.Rows[vt].Cells[3].Value.ToString());
                int manv    = int.Parse(dgvNV.Rows[vt].Cells[0].Value.ToString());
                try
                {
                    if (doan.insertNVTheoDoan(manv, madoan, nhiemVu))
                    {
                        flag2 = 0;
                    }
                    else
                    {
                        flag2 = 1;
                        MessageBox.Show("thêm nhân viên thất bại");
                        break;
                    }
                }
                catch (Exception) { }
            }
            if (flag == 0)
            {
                MessageBox.Show("Thêm nhân viên của đoàn thành công");
            }

            //Thêm chi tiết đoàn
            int flag3 = 0;

            for (int i = 0; i < dgvKH.RowCount - 1; i++)
            {
                int makh = int.Parse(dgvKH.Rows[i].Cells[0].Value.ToString());
                try
                {
                    if (doan.insertCTDoan(makh, madoan))
                    {
                        flag3 = 0;
                    }
                    else
                    {
                        flag3 = 1;
                        MessageBox.Show("Thêm chi tiết đoàn thất bại");
                        break;
                    }
                }
                catch (Exception) { }
            }
            if (flag3 == 0)
            {
                MessageBox.Show("Thêm chi tiết đoàn thành công");
            }
        }