Esempio n. 1
0
        private void init()
        {
            switch (editState)
            {
            case EditState.View:
            {
                ChiTieu ct = _chiTieuRepository.getById(_id);
                CTname.Text      = ct.Ten;
                CTname.Enabled   = false;
                Submitbt.Enabled = false;
                break;
            }

            case EditState.Edit:
            {
                ChiTieu ct = _chiTieuRepository.getById(_id);
                CTname.Text = ct.Ten;
                break;
            }

            case EditState.Create:
            {
                break;
            }
            }
        }
Esempio n. 2
0
        private List <String> listCT()
        {
            List <String> listRT = new List <String>();
            var           count  = 0;

            for (int i = 0; i < lv_radio.Items.Count; i++)
            {
                if (lv_radio.Items[i].Checked == true)
                {
                    count++;
                    ChiTieu ct = _ctRepo.getById(int.Parse(lv_radio.Items[i].Text));
                    listRT.Add(ct.Ten);
                    listRT.Add(txt_option.Text);
                }
            }

            if (count <= 0)
            {
                listRT.Clear();
            }

            return(listRT);
        }
Esempio n. 3
0
 private void Submitbt_Click_1(object sender, EventArgs e)
 {
     if (check())
     {
         return;
     }
     if (_id != -1)
     {
         ChiTieu ct = _chiTieuRepository.getById(_id);
         ct.Ten = CTname.Text;
         _chiTieuRepository.Update(ct);
         MessageBox.Show("Sửa thành công Chi tiêu");
         Program.Form.TabRefresh(ListTab.Chitieu);
     }
     else
     {
         ChiTieu ct = new ChiTieu();
         ct.Ten = CTname.Text;
         _chiTieuRepository.Add(ct);
         MessageBox.Show("Thêm thành công Chi tiêu");
         Program.Form.TabRefresh(ListTab.Chitieu);
         this.Close();
     }
 }
Esempio n. 4
0
 public void Update(ChiTieu chiTieu)
 {
     _context.ChiTieus.Update(chiTieu);
     _context.SaveChanges();
 }
Esempio n. 5
0
 public void Delete(ChiTieu chiTieu)
 {
     _context.ChiTieus.Remove(chiTieu);
     _context.SaveChanges();
 }
Esempio n. 6
0
 public void Add(ChiTieu chiTieu)
 {
     _context.ChiTieus.Add(chiTieu);
     _context.SaveChanges();
 }
Esempio n. 7
0
        private void save()
        {
            //init Create Type
            DoanKhach doan  = new DoanKhach();
            Tour      tour1 = _tourRepository.getByName(tourd.SelectedItem.ToString());

            //init Edit Type
            if (formType == EditState.Edit)
            {
                doan = _doanRepo.getById(id);
                if (tour1.TourId != doan.TourId)
                {
                    doan.Gia = tour1.Gias.LastOrDefault();
                }
            }



            //Add value to each of column doan

            doan.MaDoan    = mad.Text;
            doan.TenDoan   = tend.Text;
            doan.Tour      = tour1;
            doan.Chitiet   = statusd.Text;
            doan.DateStart = datestart.Value.Date;
            doan.DateEnd   = dateend.Value.Date;

            //NhanVien
            List <NV_VT> doan_nvs = new List <NV_VT>();

            foreach (DataGridViewRow row in data_nv.Rows)
            {
                NV_VT    doan_nv  = new NV_VT();
                NhanVien nhanvien = _nvRepo.getById(0, row.Cells[0].Value.ToString());
                doan_nv.NhanVien  = nhanvien;
                doan_nv.DoanKhach = doan;
                doan_nv.ViTri     = row.Cells[2].Value.ToString();
                doan_nvs.Add(doan_nv);
            }
            doan.NV_VTs = doan_nvs;

            //HanhKhach
            List <CTDoan> cTDoans = new List <CTDoan>();

            foreach (DataGridViewRow row in data_hk.Rows)
            {
                CTDoan    cTDoan = new CTDoan();
                HanhKhach hk     = _hkRepo.getById(0, row.Cells[0].Value.ToString());
                cTDoan.HanhKhach = hk;
                cTDoan.DoanKhach = doan;
                cTDoans.Add(cTDoan);
            }
            doan.CTDoans = cTDoans;

            //ChiTieu
            List <CTChitieu> cTChiTieus = new List <CTChitieu>();

            foreach (DataGridViewRow row in data_cp.Rows)
            {
                CTChitieu cTChiTieu = new CTChitieu();
                ChiTieu   ct        = _ctRepo.getByName(row.Cells[0].Value.ToString());
                cTChiTieu.ChiTieu   = ct;
                cTChiTieu.TienCT    = row.Cells[1].Value.ToString();
                cTChiTieu.DoanKhach = doan;
                cTChiTieus.Add(cTChiTieu);
            }
            doan.CTChitieus = cTChiTieus;
            if (formType == EditState.Edit)
            {
                _doanRepo.Update(doan);
            }
            else
            {
                doan.Gia         = doan.Tour.Gias.LastOrDefault();
                doan.DateCreated = DateTime.Now;
                _doanRepo.Add(doan);
            }
        }