Esempio n. 1
0
        public ActionResult DeleteConfirmed(string id)
        {
            TAISAN tAISAN = db.TAISANs.Find(id);

            db.TAISANs.Remove(tAISAN);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
 public ActionResult Edit([Bind(Include = "MaTS,TenTS,DVT,XuatXu,DonGia,AnhMH,GhiChu,MaLTS")] TAISAN tAISAN)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tAISAN).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MaLTS = new SelectList(db.LOAITS, "MaLTS", "TenLTS", tAISAN.MaLTS);
     return(View(tAISAN));
 }
Esempio n. 3
0
 public void AddTS(TAISAN myTS)
 {
     db.TAISANs.Add(myTS);
     try
     {
         db.SaveChanges();
     }
     catch (DbEntityValidationException ex)
     {
     }
 }
Esempio n. 4
0
        // GET: TaiSan_59130033/Details/5/123
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TAISAN tAISAN = db.TAISANs.Find(id);

            if (tAISAN == null)
            {
                return(HttpNotFound());
            }
            return(View(tAISAN));
        }
Esempio n. 5
0
        // GET: TaiSan_59130033/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TAISAN tAISAN = db.TAISANs.Find(id);

            if (tAISAN == null)
            {
                return(HttpNotFound());
            }
            ViewBag.MaLTS = new SelectList(db.LOAITS, "MaLTS", "TenLTS", tAISAN.MaLTS);
            return(View(tAISAN));
        }
Esempio n. 6
0
 public ActionResult Edit(TAISAN TaiSan)
 {
     if (ModelState.IsValid)
     {
         if (cc.EditKHO(TaiSan))
         {
             return(RedirectToAction("Index", "TaiSan"));
         }
         else
         {
             ModelState.AddModelError("", "Thêm không hợp lệ " + TaiSan.TEN);
         }
     }
     return(View());
 }
Esempio n. 7
0
 public ActionResult Create(TAISAN taiSan)
 {
     if (ModelState.IsValid)
     {
         if (cc.CreateKHO(taiSan))
         {
             return(RedirectToAction("Index", "TAISAN"));
         }
         else
         {
             ModelState.AddModelError("", "Đã có sản phẩm tên :" + taiSan.TEN + " và loại :" + taiSan.LOAI);
         }
     }
     return(View());
 }
Esempio n. 8
0
        public void AddCTG(CHUNGTUGIAM myCTG)
        {
            db.CHUNGTUGIAMs.Add(myCTG);
            var    s    = db.TAISANs.Single(p => p.MaTS == myCTG.MaTS);
            TAISAN myTS = s;

            myTS.SoLuong = myTS.SoLuong - myCTG.SoLuong;
            try
            {
                db.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
            }
        }
Esempio n. 9
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            TAISAN newTS = new TAISAN();

            newTS.MaChungTuTang = comboBoxMaCTT.SelectedValue.ToString();
            newTS.NgayGhiTang   = dateTimePickerGhiTang.Value;
            newTS.SoLuongCTT    = int.Parse(numericUpDownSoLuong.Value.ToString());
            int tien;

            Int32.TryParse(textBoxThanhTien.Text, out tien);
            newTS.ThanhTien = tien;
            newTS.NoiDung   = textBoxNoiDung.Text;

            d.Invoke(newTS, SoLuongCu);
            this.Close();
        }
Esempio n. 10
0
        public void SuaCTT(TAISAN newTS, int SoLuongCu)
        {
            var    s    = db.TAISANs.Single(p => p.MaChungTuTang == newTS.MaChungTuTang);
            TAISAN myTS = s;

            myTS.NgayGhiTang = newTS.NgayGhiTang;
            myTS.SoLuongCTT  = newTS.SoLuongCTT;
            myTS.ThanhTien   = newTS.ThanhTien;
            myTS.NoiDung     = newTS.NoiDung;
            myTS.SoLuong     = myTS.SoLuong + newTS.SoLuongCTT - SoLuongCu;

            try
            {
                db.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
            }
        }
Esempio n. 11
0
 public ActionResult CreatePhong(FormCollection collection, TAISAN taisan)
 {
     if (ModelState.IsValid)
     {
         int idPhong = 0;
         int.TryParse(collection["var1"], out idPhong);
         taisan.IDPHONG = idPhong;
         if (cc.CreatePhong(taisan))
         {
             return(RedirectToAction("Index", "TaiSan"));
         }
         else
         {
             ModelState.AddModelError("", "Số lượng chọn lớn hơn số lượng của tài sản");
         }
     }
     ViewBag.var1 = new SelectList(cc.LoadPhong(0), "ID", "TENPHONG");
     return(View(cc.Get(taisan.ID)));
 }
Esempio n. 12
0
        public void XoaCTT(string id)
        {
            var    s    = db.TAISANs.Single(p => p.MaChungTuTang == id);
            TAISAN myTS = s;

            db.TAISANs.Remove(myTS);
            var ha = db.CHUNGTUGIAMs.Where(p => p.MaTS == id);

            foreach (CHUNGTUGIAM ob in ha)
            {
                db.CHUNGTUGIAMs.Remove(ob);
            }
            try
            {
                db.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
            }
        }
Esempio n. 13
0
        public void SuaTS(TAISAN newTS)
        {
            var    s    = db.TAISANs.Single(p => p.MaTS == newTS.MaTS);
            TAISAN myTS = s;

            myTS.MaLoaiTS       = newTS.MaLoaiTS;
            myTS.MaPhong        = newTS.MaPhong;
            myTS.ThongSoKyThuat = newTS.ThongSoKyThuat;
            myTS.SoLuong        = newTS.SoLuong;
            myTS.GhiChu         = newTS.GhiChu;
            myTS.TenTS          = newTS.TenTS;
            myTS.TyLeHM         = newTS.TyLeHM;
            myTS.TyLeCL         = newTS.TyLeCL;

            try
            {
                db.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
            }
        }
Esempio n. 14
0
        public void SuaCTG(CHUNGTUGIAM newCTG, int SoLuongCu)
        {
            var         s     = db.CHUNGTUGIAMs.Single(p => p.MaChungTuGiam == newCTG.MaChungTuGiam);
            CHUNGTUGIAM myCTG = s;

            myCTG.SoLuong     = newCTG.SoLuong;
            myCTG.NgayGhiGiam = newCTG.NgayGhiGiam;
            myCTG.NoiDung     = newCTG.NoiDung;
            myCTG.GhiChu      = newCTG.GhiChu;
            myCTG.ThanhTien   = newCTG.ThanhTien;

            var    x    = db.TAISANs.Single(p => p.MaTS == newCTG.MaTS);
            TAISAN myTS = x;

            myTS.SoLuong = myTS.SoLuong + SoLuongCu - myCTG.SoLuong;

            try
            {
                db.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
            }
        }
Esempio n. 15
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (!checkBox1.Checked)
            {
                TAISAN fixTS = new TAISAN();
                fixTS.MaTS           = comboBoxMaTS.SelectedValue.ToString();
                fixTS.MaLoaiTS       = bll.GetMaLoaiTS(comboBoxTenLoaiTS.SelectedValue.ToString());
                fixTS.MaPhong        = bll.GetMaPhong(comboBoxPhong.SelectedValue.ToString());
                fixTS.SoLuong        = bll.GetMaxSoLuong(fixTS.MaTS);
                fixTS.ThongSoKyThuat = textBoxTSKT.Text;
                fixTS.GhiChu         = textBoxGhiChu.Text;
                fixTS.TenTS          = textBoxTenTS.Text;
                fixTS.TyLeHM         = int.Parse(numericUpDownTyLeHM.Value.ToString());
                fixTS.TyLeCL         = int.Parse(numericUpDownTyLeCL.Value.ToString());

                d.Invoke(fixTS);
            }
            else
            {
                if (numericUpDown1.Value == bll.GetMaxSoLuong(comboBoxMaTS.SelectedValue.ToString()))
                {
                    TAISAN fixTS = new TAISAN();
                    fixTS.MaTS           = comboBoxMaTS.SelectedValue.ToString();
                    fixTS.MaLoaiTS       = bll.GetMaLoaiTS(comboBoxTenLoaiTS.SelectedValue.ToString());
                    fixTS.MaPhong        = bll.GetMaPhong(comboBoxPhongMoi.SelectedValue.ToString());
                    fixTS.ThongSoKyThuat = textBoxTSKT.Text;
                    fixTS.GhiChu         = textBoxGhiChu.Text;
                    fixTS.TenTS          = textBoxTenTS.Text;
                    fixTS.TyLeHM         = int.Parse(numericUpDownTyLeHM.Value.ToString());
                    fixTS.TyLeCL         = int.Parse(numericUpDownTyLeCL.Value.ToString());
                    fixTS.SoLuong        = int.Parse(numericUpDown1.Value.ToString());

                    d.Invoke(fixTS);
                }
                else
                {
                    TAISAN fixTS = new TAISAN();
                    fixTS.MaTS           = comboBoxMaTS.SelectedValue.ToString();
                    fixTS.MaLoaiTS       = bll.GetMaLoaiTS(comboBoxTenLoaiTS.SelectedValue.ToString());
                    fixTS.MaPhong        = bll.GetMaPhong(comboBoxPhong.SelectedValue.ToString());
                    fixTS.ThongSoKyThuat = textBoxTSKT.Text;
                    fixTS.GhiChu         = textBoxGhiChu.Text;
                    fixTS.TenTS          = textBoxTenTS.Text;
                    fixTS.TyLeHM         = int.Parse(numericUpDownTyLeHM.Value.ToString());
                    fixTS.TyLeCL         = int.Parse(numericUpDownTyLeCL.Value.ToString());
                    fixTS.SoLuong        = bll.GetMaxSoLuong(comboBoxMaTS.SelectedValue.ToString()) - (int)numericUpDown1.Value;


                    TAISAN newTS = new TAISAN();

                    newTS.MaLoaiTS       = bll.GetMaLoaiTS(comboBoxTenLoaiTS.SelectedValue.ToString());
                    newTS.MaPhong        = bll.GetMaPhong(comboBoxPhongMoi.SelectedValue.ToString());
                    newTS.ThongSoKyThuat = textBoxTSKT.Text;
                    newTS.GhiChu         = textBoxGhiChu.Text;
                    newTS.TenTS          = textBoxTenTS.Text;
                    newTS.NgayGhiTang    = DateTime.Today;
                    newTS.TyLeHM         = int.Parse(numericUpDownTyLeHM.Value.ToString());
                    newTS.TyLeCL         = int.Parse(numericUpDownTyLeCL.Value.ToString());
                    newTS.SoLuong        = (int)numericUpDown1.Value;
                    newTS.SoLuongCTT     = newTS.SoLuong;
                    newTS.MaChungTuTang  = "04-TSCĐ-" + RandomString(8);


                    string MaLoaiTaiSan = ""; MaLoaiTaiSan = newTS.MaLoaiTS;
                    string MaPhong      = ""; MaPhong = newTS.MaPhong;

                    newTS.MaTS = bll.getMaTaiSan(MaLoaiTaiSan, MaPhong);
                    bll.AddTS(newTS);
                    d.Invoke(fixTS);
                }
            }
            this.Close();
            MessageBox.Show("Sửa tài sản thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Esempio n. 16
0
 public void SuaCTT(TAISAN newTS, int SoLuongCu)
 {
     dal.SuaCTT(newTS, SoLuongCu);
 }
Esempio n. 17
0
 public void SuaTS(TAISAN newTS)
 {
     dal.SuaTS(newTS);
 }
Esempio n. 18
0
 public void AddTS(TAISAN myTS)
 {
     dal.AddTS(myTS);
 }
Esempio n. 19
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            // Check textBoxMaTS, textBoxMaCTT == null or duplicated ?
            bool isGoodToGo = true;

            if (String.IsNullOrEmpty(textBoxMaTS.Text.Trim()))
            {
                MessageBox.Show("Nhập lại mã tài sản", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                isGoodToGo = false;
            }
            foreach (object ob in bll.GetListMaTS())
            {
                if (textBoxMaTS.Text.Equals(ob.ToString()))
                {
                    MessageBox.Show("Nhập lại mã tài sản", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    isGoodToGo = false;
                    break;
                }
            }

            if (String.IsNullOrEmpty(textBoxMaCTT.Text.Trim()))
            {
                MessageBox.Show("Nhập lại mã chứng từ tăng", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                isGoodToGo = false;
            }

            foreach (string ob in bll.GetListMaCTT())
            {
                if (textBoxMaCTT.Text.Equals(ob.ToString()))
                {
                    MessageBox.Show("Nhập lại mã chứng từ tăng", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    isGoodToGo = false;
                    break;
                }
            }

            if (isGoodToGo)
            {
                TAISAN myTS = new TAISAN();
                myTS.MaTS           = textBoxMaTS.Text;
                myTS.MaLoaiTS       = bll.GetMaLoaiTS(comboBoxTenLoaiTS.SelectedValue.ToString());
                myTS.MaPhong        = bll.GetMaPhong(comboBox1.SelectedValue.ToString());
                myTS.TenTS          = textBoxTenTS.Text;
                myTS.MaChungTuTang  = textBoxMaCTT.Text;
                myTS.ThongSoKyThuat = textBoxTSKT.Text;
                int tien;
                Int32.TryParse(textBoxThanhTien.Text, out tien);
                myTS.ThanhTien   = tien;
                myTS.SoLuong     = myTS.SoLuongCTT = int.Parse(numericUpDownSoLuong.Value.ToString());
                myTS.TyLeHM      = int.Parse(numericUpDownTyLeHM.Value.ToString());
                myTS.TyLeCL      = int.Parse(numericUpDownTyLeCL.Value.ToString());
                myTS.GhiChu      = textBoxGhiChu.Text;
                myTS.NgayGhiTang = DateTime.Parse(dateTimePickerGhiTang.Value.ToShortDateString());
                myTS.NoiDung     = textBoxNoiDung.Text;
                d.Invoke(myTS);

                this.Close();
                MessageBox.Show("Thêm tài sản thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 20
0
        private void importFromXLSToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Microsoft Excel(*.xls)|*.xls";
            string filepath = "";

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                filepath = Path.GetFullPath(ofd.FileName);
                string path = AppDomain.CurrentDomain.BaseDirectory + "log.txt";
                if (!File.Exists(path))
                {
                    File.Create(path);
                }
                TextWriter tw = new StreamWriter(path, true);

                Excel.Application xlApp = new Excel.Application();
                Excel.Workbook    xlWorkBook;
                Excel.Range       range;
                xlApp      = new Excel.Application();
                xlWorkBook = xlApp.Workbooks.Open(filepath, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                int count = 0;
                foreach (Worksheet xlWorkSheet in xlWorkBook.Worksheets)
                {
                    int begini, beginj;
                    begini = 12;
                    beginj = 2;
                    while (xlWorkSheet.Cells[begini, beginj].Value2 != null)
                    {
                        TAISAN ts = new TAISAN();
                        ts.MaTS = xlWorkSheet.Cells[begini, beginj].Value2.ToString();

                        try
                        {
                            ts.MaPhong = bll.GetMaPhong(xlWorkSheet.Name);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Lỗi tên phòng");
                        }
                        ts.MaLoaiTS       = xlWorkSheet.Cells[begini, beginj + 1].Value2.ToString();
                        ts.NgayGhiTang    = Convert.ToDateTime("1/1/" + xlWorkSheet.Cells[begini, beginj + 2].Value2.ToString());
                        ts.TenTS          = xlWorkSheet.Cells[begini, beginj + 3].Value2.ToString();
                        ts.ThongSoKyThuat = xlWorkSheet.Cells[begini, beginj + 4].Value2.ToString();
                        ts.SoLuong        = int.Parse(xlWorkSheet.Cells[begini, beginj + 5].Value2.ToString());
                        ts.ThanhTien      = int.Parse(xlWorkSheet.Cells[begini, beginj + 6].Value2.ToString());
                        ts.TyLeCL         = int.Parse(xlWorkSheet.Cells[begini, beginj + 7].Value2.ToString());
                        ts.TyLeHM         = int.Parse(xlWorkSheet.Cells[begini, beginj + 12].Value2.ToString());
                        ts.MaChungTuTang  = RandomString(8);
                        try
                        {
                            count++;
                            bll.AddTS(ts);
                        }
                        catch (Exception ex)
                        {
                            tw.WriteLine("**********" + DateTime.Now + "**********");
                            tw.WriteLine("Imported File: " + filepath + "Line " + begini);
                            count--;
                            begini++;
                            continue;
                        }

                        if (xlWorkSheet.Cells[begini, beginj + 13].Value2 != null)
                        {
                            CHUNGTUGIAM ctg = new CHUNGTUGIAM();
                            ctg.MaChungTuGiam = ts.MaTS + "ctg";
                            ctg.MaTS          = ts.MaTS;
                            ctg.NgayGhiGiam   = Convert.ToDateTime("1/1/" + xlWorkSheet.Cells[begini, beginj + 13].Value2.ToString());
                            ctg.NoiDung       = xlWorkSheet.Cells[begini, beginj + 14].Value2.ToString();
                            ctg.SoLuong       = int.Parse(xlWorkSheet.Cells[begini, beginj + 15].Value2.ToString());
                            ctg.ThanhTien     = int.Parse(xlWorkSheet.Cells[begini, beginj + 16].Value2.ToString());
                            ctg.GhiChu        = xlWorkSheet.Cells[begini, beginj + 17].Value2.ToString();
                            MessageBox.Show(ctg.MaChungTuGiam);
                            bll.AddCTG(ctg);
                        }
                        begini++;
                    }
                    tw.Close();
                }

                MessageBox.Show("Có " + count.ToString() + " hàng dữ liệu được nhập thành công!");
                MessageBox.Show("Các hàng lỗi được ghi ra ở file " + AppDomain.CurrentDomain.BaseDirectory + "log.txt");
            }
        }
Esempio n. 21
0
        //TAB CTT

        private void suaCTT(TAISAN newTS, int SoLuongCu)
        {
            bll.SuaCTT(newTS, SoLuongCu);
            showCTT();
        }
Esempio n. 22
0
 private void editTS(TAISAN newTS)
 {
     bll.SuaTS(newTS);
     showTS();
 }
Esempio n. 23
0
        //Xử lý Tab TAISAN

        private void addTS(TAISAN myTS)
        {
            bll.AddTS(myTS);
            showTS();
        }
Esempio n. 24
0
 public bool CreatePhong(TAISAN Taisan)
 {
     return(DataProvider.Instance.ExcuteNonQuery("pCreateTaiSanPhong @idLoai , @idPhong , @SoLuong", new object[] { Taisan.ID, Taisan.IDPHONG, Taisan.SOLUONG }) > 0);
 }
Esempio n. 25
0
 public bool EditKHO(TAISAN Taisan)
 {
     return(DataProvider.Instance.ExcuteNonQuery("pEditTaiSanKho @id , @Ten , @loai , @gia , @soLuong , @status ", new object[] { Taisan.ID, Taisan.TEN, Taisan.LOAI, Taisan.GIA, Taisan.SOLUONG, Taisan.STATUS }) > 0);
 }