コード例 #1
0
        // GET: CongNo/Edit/5
        public ActionResult Edit(int?id)
        {
            CongNo obj = new CongNo()
            {
                State = Notify.INIT
            };

            if (id > 0)
            {
                obj          = db.CongNoes.Find(id);
                obj.Cong     = obj.MaCongNo.StartsWith("CONG_");
                obj.MaCongNo = obj.MaCongNo.StartsWith("NO_") ? obj.MaCongNo.Remove(0, "NO_".Length) : (obj.MaCongNo.StartsWith("CONG_") ? obj.MaCongNo.Remove(0, "CONG_".Length) : obj.MaCongNo);
            }
            ViewBag.IDQuys = db.Quys.Where(q => q.State != Notify.CANCLE).CreateSelectList(q => q.IDQuy, q => q.mName, obj.IDQuy);
            return(View(obj));
        }
コード例 #2
0
ファイル: UcCongNo.cs プロジェクト: thachgiasoft/QLDT
        private void UpdateCongNo(CongNo congNo)
        {
            var thanhToan = PrimitiveConvert.StringToInt(ThanhToanCongNo_ThanhToan.Text);
            var no        = PrimitiveConvert.StringToInt(CongNo_No.Text);

            congNo.No = Math.Max(no - thanhToan, 0);
            CRUD.DbContext.CongNoes.AddOrUpdate(congNo);

            // Update chi tiet cong no
            var thanhToanCongNo = CRUD.GetFormObject <ThanhToanCongNo>(FormControls);

            if (thanhToanCongNo.ThanhToan > 0)
            {
                thanhToanCongNo.CongNoId = congNo.Id;
                CRUD.DecorateSaveData(thanhToanCongNo);
                CRUD.DbContext.ThanhToanCongNoes.Add(thanhToanCongNo);
            }

            CRUD.DbContext.SaveChanges();
        }
コード例 #3
0
        public List <CongNo> GetList()
        {
            List <CongNo> list = new List <CongNo>();

            string sqlQuery = "select * from CongNo";

            reader = ExecuteReader(sqlQuery);

            while (reader.Read())
            {
                CongNo congNo = new CongNo();

                congNo.MaCN     = reader["MaCN"].ToString();
                congNo.MaKH     = reader["MaKH"].ToString();
                congNo.ThoiGian = (DateTime)reader["ThoiGian"];
                congNo.SoTien   = (double)reader["SoTien"];
                congNo.DaTra    = (double)reader["DaTra"];

                list.Add(congNo);
            }

            return(list);
        }
コード例 #4
0
        public ActionResult Edit(CongNo obj)
        {
            obj.MaCongNo = $"{ (obj.Cong ? "CONG" : "NO")}_{obj.MaCongNo}";
            if (obj.IDCongNo > 0)
            {
                db.Entry(obj).State = EntityState.Modified;
            }
            else
            {
                obj.State      = Notify.INIT;
                obj.CreateBy   = Account.IDTaiKhoan;
                obj.CreateTime = DateTime.Now;
                obj.ConNo      = obj.Tra1Ngay * (obj.NgayTra - obj.CreateTime).Value.Days ?? 0;
                obj.Payed      = 0;
                db.CongNoes.Add(obj);
            }

            if (db.SaveChanges() > 0)
            {
                UpdateQuy(obj.IDQuy ?? 0, (obj.Cong ? -1 : 1) * obj.SoTien);
            }
            return(RedirectToAction("Index"));
        }
コード例 #5
0
ファイル: UcCongNo.cs プロジェクト: thachgiasoft/QLDT
        public UcCongNo(Define.LoaiDonHangEnum loaiDonHang, CongNo data)
        {
            InitializeComponent();

            Init(data);
            _domainData  = data;
            _loaiDonHang = loaiDonHang;

            if (loaiDonHang == Define.LoaiDonHangEnum.XuatKho)
            {
                lblKhachHangId.Text = "Khách Hàng";
            }

            ThanhToanCongNo_NgayThanhToan.Text = TimeHelper.TimestampToString(TimeHelper.CurrentTimeStamp());

            // Khoi tao thong tin khach hang
            KhachHang.Text = data.KhachHang.Ten;
            NgayLap.Text   = data.NgayLap.ToShortDateString();

            if (data.DonHang != null)
            {
                var donHang = data.DonHang;
                TongCong.Text = donHang.TongCong.ToString();

                // Thong tin don hang
                _chiTietDonHangs = donHang.ChiTietDonHangs.ToList();
                gridControlChiTiet.DataSource = _chiTietDonHangs;
            }

            // Lich su thanh toan
            _thanhToanCongNoes           = data.ThanhToanCongNoes.ToList();
            gridControlNhatKy.DataSource = _thanhToanCongNoes;

            // Lich su cong no
            _congNoes = data.KhachHang.CongNoes.Where(s => s.No > 0).ToList();
            gridControlCongNo.DataSource = _congNoes;
        }