private BUS.Contact FromEntity(BUS.Contact contact)
 {
     return new BUS.Contact
     {
         Id = contact.Id,
         FirstName = contact.FirstName,
         LastName = contact.LastName,
         Email = contact.Email,
         LuckyNumber = contact.LuckyNumber
     };
 }
Example #2
0
        public void Save(BUS.Contact contact, List<BUS.Friend> friends)
        {
            var toDelete = DB.Friends.Where(f => f.ContactId1 == contact.Id || f.ContactId2 == contact.Id);
            DB.Friends.DeleteAllOnSubmit(toDelete);
            foreach (var friend in friends)
            {
                DB.Friends.InsertOnSubmit(new Friend { ContactId1 = friend.ContactId1, ContactId2 = friend.ContactId2 });
            }

            DB.SubmitChanges();
        }
 private database.Contact FromEntity(entity.Contact contact)
 {
     return new database.Contact
     {
         Id = contact.Id,
         FirstName = contact.FirstName,
         LastName = contact.LastName,
         Email = contact.Email,
         LuckyNumber = contact.LuckyNumber
     };
 }
        private XElement ToXElement(BUS.Contact contact)
        {
            var node =  new XElement("Contact",
                        new XElement("Id", contact.Id),
                        new XElement("FirstName", contact.FirstName),
                        new XElement("LastName", contact.LastName),
                        new XElement("Email", contact.Email)
                );

            if (contact.LuckyNumber.HasValue)
                node.Add(new XElement("LuckyNumber", contact.LuckyNumber.Value));

            return node;
        }
Example #5
0
        private void btn_save_Click(object sender, EventArgs e)
        {
            KeSach ks2 = new KeSach();

            ks2.MaKe    = txt_MaKe.Text; ks2.ChatLieu = txt_CL.Text;
            ks2.SucChua = txt_SC.Text;


            if (insert)
            {
                if (MessageBox.Show("Bạn muốn lưu dữ liệu được thêm mơi không???", "SAVE", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    DataTable test = new DataTable(); //  kiểm tra mã đã  có trong bảng chưa???

                    string sql = "select *from KeSach where MaKe= '" + txt_MaKe.Text + "'";
                    test = DataProvider.GetData(sql);
                    int i = test.Rows.Count;
                    if (i > 0)
                    {
                        MessageBox.Show("Đã tồn tại " + txt_MaKe.Text, "Error !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        gridControl2.DataSource = BUS.Insert_KeSach(ks2);
                        MessageBox.Show("Đã lưu thành công");
                        gridControl2.DataSource = BUS.Select_KeSach();
                    }
                }
            }
            if (update)
            {
                if (MessageBox.Show("Bạn muốn lưu thay đổi không???", "SAVE", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    gridControl2.DataSource = BUS.Update_KeSach(ks2);
                    MessageBox.Show("Đã lưu thành công");
                    gridControl2.DataSource = BUS.Select_KeSach();
                }
            }
            txt_MaKe.Enabled   = false;
            btn_cancel.Enabled = false;
            btn_save.Enabled   = false;
            btn_delete.Enabled = true;
            btn_update.Enabled = true;
            btn_insert.Enabled = true;
        }
Example #6
0
        /// <summary>
        /// This will setup the direction of the BUS and force a value on the bits that are set as output.
        /// A 1 in the Direction byte will make that bit an output, 0 an input
        /// </summary>
        /// <param name="bus"></param>
        /// <param name="value"></param>
        /// <param name="direction"></param>
        byte[] formSetDataBits(BUS bus = BUS.ADBUS, byte value = 0x00, byte direction = 0x00)
        {
            /*
             * byte opcode = 0x80; // Low byte ADBUS
             * if(bus == BUS.ACBUS) // High byte ACBUS
             * {
             *  opcode = 0x82;
             * }*/

            List <byte> buffer = new List <byte>();
            byte        opcode = (byte)bus;

            buffer.Add(opcode);
            buffer.Add(value);
            buffer.Add(direction);

            return(buffer.ToArray());
        }
        public ActionResult Show_Bus(BUS model)
        {
            var a = (from r in db.Buses
                     where r.Num_Seats == model.Num_Seats

                     select new DriverDetails()
            {
                ID_Bus = r.ID_Bus,
                Name_Bus = r.Name_Bus,
                Number_Bus = r.Number_Bus,
                Num_Seats = r.Num_Seats,
                Reliability = r.Reliability,
                Date_LastTO = r.Date_LastTO
            }).ToList();

            ;
            ViewBag.Num = model.Num_Seats;
            return(View(a));
        }
Example #8
0
        private void loadDG()
        {
            DataTable dt = BUS.xuat_DGcoMa(txtMDG1.Text.Trim());

            if (dt.Rows.Count == 1)
            {
                txtTenDG.Text = Convert.ToString(dt.Rows[0].ItemArray[1]);
                if (Convert.ToString(dt.Rows[0].ItemArray[2]) == "Nam")
                {
                    rdbNam.Checked = true;
                }
                else
                {
                    rdbNu.Checked = true;
                }
                txtNgaySinh.Text = Convert.ToDateTime(dt.Rows[0].ItemArray[3]).ToShortDateString();
                txtSDT.Text      = Convert.ToString(dt.Rows[0].ItemArray[5]);
                txtLoai.Text     = Convert.ToString(dt.Rows[0].ItemArray[6]);
            }
        }
Example #9
0
        private void loadDataToDgv()
        {
            dgvTG.DataSource = BUS.xuat_TG();
            DataGridViewCheckBoxColumn cl = new DataGridViewCheckBoxColumn();

            cl.Name       = "check";
            cl.HeaderText = "Check";
            dgvTG.Columns.Insert(0, cl);
            foreach (DataGridViewRow row in dgvTG.Rows)
            {
                if (maTG != null && maTG.Contains(row.Cells[1].Value.ToString()))
                {
                    row.Cells[0].Value = true;
                }
                else
                {
                    row.Cells[0].Value = false;
                }
            }
        }
Example #10
0
        public GBA(ushort[] display)
        {
            this.cpu = new ARM7TDMI(this, this.EventQueue);
            this.IO  = this.cpu.IO;
            this.mem = this.cpu.mem;
            this.bus = this.cpu.bus;

            this.apu = new APU(this.cpu, this.EventQueue);
            this.ppu = new PPU(this, display, this.IO);

            this.mem.Init(this.ppu);
            this.IO.Init(this.ppu, this.bus);
            this.IO.Layout(this.cpu, this.apu);

            // this.mem.UseNormattsBIOS();

            this.display = display;
#if THREADED_RENDERING
            this.RenderThread = new Thread(() => ppu.Mainloop());
#endif
        }
Example #11
0
                static void Main()
                {
                    Console.WriteLine("Количество автобус: ");
                    int n = Convert.ToInt32(Console.ReadLine());

                    BUS[] bUs = new BUS[n];
                    int   i;

                    for (i = 0; i < n; i++)
                    {
                        bUs[i] = new BUS();
                        bUs[i].Show();
                    }


                    for (i = 0; n > i; i++)
                    {
                        if (bUs[i].data > 10)
                        {
                            Console.WriteLine($"Автобус №{bUs[i].bus} возрастом старше 10 лет ");
                        }
                        if (bUs[i].probeg > 1000)
                        {
                            Console.WriteLine($"Пробег у автосу №{bUs[i].bus} больше 10000км");
                        }
                    }

                    while (true)
                    {
                        Console.WriteLine("выберите номер маршрута:");
                        int m = Convert.ToInt32(Console.ReadLine());
                        for (i = 0; n > i; i++)
                        {
                            if (bUs[i].rout == m)
                            {
                                Console.WriteLine($"Атобус №{bUs[i].bus}, едет по маршруту №{bUs[i].rout}");
                            }
                        }
                    }
                }
Example #12
0
        private void btn_delete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có muốn xóa hay không", "DELETE", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                DataTable kttt = new DataTable(); // kttt kiểm tra thông tin có trong bảng khác không???

                string sql = "select *from TuaSach where MaKe= '" + txt_MaKe.Text + "'";
                kttt = DataProvider.GetData(sql);
                int i = kttt.Rows.Count;
                if (i > 0)
                {
                    MessageBox.Show("Dữ liệu " + txt_MaKe.Text + " có trong bảng TuaSach!", "Error !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    ks.MaKe = txt_MaKe.Text;
                    gridControl2.DataSource = BUS.Delete_KeSach(ks);
                    MessageBox.Show("Đã xóa thành công");
                    gridControl2.DataSource = BUS.Select_KeSach();
                }
            }
        }
Example #13
0
        private void loaddgv()
        {
            string i, j;

            if (comtl.Text.Length == 0)
            {
                i = "";
            }
            else
            {
                i = comtl.SelectedValue.ToString();
            }
            if (comtg.Text.Length == 0)
            {
                j = "";
            }
            else
            {
                j = comtg.SelectedValue.ToString();
            }
            dataGridView1.DataSource = BUS.search(txttesach.Text, "", i, j);
        }
Example #14
0
        private void getTGcuaTS()
        {
            maTGcu     = null;
            txtTG.Text = null;
            DataTable dtTGcuaTS = BUS.xuat_TGcuaTS(txtMTS.Text);

            foreach (DataRow row in dtTGcuaTS.Rows)
            {
                maTGcu     += Convert.ToString(row.ItemArray[0]) + ";";
                txtTG.Text += Convert.ToString(row.ItemArray[1]) + ";";
            }
            if (txtTG.Text != null && txtTG.Text != "")
            {
                txtTG.Text = txtTG.Text.Remove(txtTG.Text.Length - 1);
            }
            if (maTGcu != null)
            {
                maTGcu = maTGcu.Remove(maTGcu.Length - 1);
            }
            dtTGcuaTS.Clear();
            dtTGcuaTS.Dispose();
        }
Example #15
0
 //Xoa
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (btnThem.Active || btnSua.Active)
     {
         clearInput();
         disbleInput();
         btnXoa.Text     = "Xóa";
         btnXoa.Active   = true;
         btnSua.Enabled  = false;
         btnThem.Enabled = true;
     }
     else
     {
         btnXoa.Text     = "Xóa";
         btnXoa.Active   = true;
         btnSua.Enabled  = false;
         btnThem.Enabled = true;
         if (txtMTS.Text != null)
         {
             if (BUS.xoa_TS(txtMTS.Text) > 0)
             {
                 updateDataToDgv();
                 MessageBox.Show("Xóa thành công");
             }
             else
             {
                 MessageBox.Show("Không xóa được");
             }
         }
         else
         {
             MessageBox.Show("Không xóa được");
         }
         clearInput();
         disbleInput();
     }
 }
Example #16
0
File: CPU.cs Project: DenSinH/GBAC-
        public ARM7TDMI(GBA gba, Scheduler.Scheduler scheduler)
        {
            this.gba      = gba;
            this.Pipeline = new cPipeline(this);

            this.InitARM();
            this.InitTHUMB();
            this.InitTimers(scheduler);

            // IO requires bus to be initialized
            this.bus = new BUS(this);
            this.IO  = new IORAMSection();

            // DMAChannels require bus AND IO to be initialized
            this.DMAChannels[0] = new DMAChannel(this, 0);
            this.DMAChannels[1] = new DMAChannel(this, 1);
            this.DMAChannels[2] = new DMAChannel(this, 2);
            this.DMAChannels[3] = new DMAChannel(this, 3);

            // mem requires IO AND DMAChannels to be initialized
            this.mem = new MEM(this);

            this.SystemBank     = new uint[16];
            this.FIQBank        = new uint[16];
            this.SupervisorBank = new uint[16];
            // this.AbortBank      = new uint[16];
            this.IRQBank = new uint[16];
            // this.UndefinedBank  = new uint[16];
            this.state = State.ARM;

            // need banked registers for CPSR initialization
            this.CPSR = 0x0000005F;

            this.PipelineFlush();
            this.PC += 4;
        }
 public BIOS_Disassembler(BUS bus)
 {
     this.bus = bus;
 }
Example #18
0
 public cBGScrolling(PPU ppu, BUS bus, bool IsLower) : base(ppu, bus, IsLower)
 {
 }
Example #19
0
        private void WriteFile(BUS.SMA sma5, BUS.SMA sma10, BUS.SMA sma20, BUS.SMA sma50, BUS.Guess_SMA gSMA5_20, BUS.Guess_SMA gSMA10_50, BUS.CCI Cci)
        {
            string buff;
            DTO.DuLieuNgay dln;
            int i5, i20, i10, i50, igSma5_20, igSma10_50,iCCI;

            i5 = 0;
            i50 = 0;
            i10 = 0;
            i20 = 0;
            igSma5_20 = 0;
            igSma10_50 = 0;
            iCCI = 0;

            StreamWriter sw = new StreamWriter(TenFile);
            sw.WriteLine("MaCK,Ngay,GiaMoCua,GiaCaoNhat,GiaThapNhat,GiaDongCua,KhoiLuongGD,GiaTran,GiaSan,GiaThamChieu,TangGiam,%,GDThoaThuan,NNMua,NNBanCOM,SMA5,SMA10,SMA20,SMA50,GUESS_SMA5_SMA20,GUESS_SMA10_SMA50,CCI");
            for (int i = 0; i < dldk.Count; i++ )
            {
                dln = (DTO.DuLieuNgay)dldk[i];
                buff = dln.MACK.ToString() + ",";
                buff = buff + dln.Ngay.ToString() + ",";
                buff = buff + dln.GiaMoCua.ToString() + ",";
                buff = buff + dln.GiaCaoNhat.ToString() + ",";
                buff = buff + dln.GiaThapNhat.ToString() + ",";
                buff = buff + dln.GiaDongCua.ToString() + ",";
                buff = buff + dln.KhoiLuongGD.ToString() + ",";
                buff = buff + dln.GiaTran.ToString() + ",";
                buff = buff + dln.GiaSan.ToString() + ",";
                buff = buff + dln.GiaThamChieu.ToString() + ",";
                buff = buff + dln.TangGiam.ToString() + ",";
                buff = buff + dln.PhanTram.ToString() + ",";
                buff = buff + dln.GDThoaThuan.ToString() + ",";
                buff = buff + dln.NNMua.ToString() + ",";
                buff = buff + dln.NNBan.ToString() + ",";

                if ((i5 < sma5.DDate.Count) && (sma5.DDate[i5] == dln.Ngay))
                {
                    buff = buff + sma5.FVals1[i5].ToString() + ",";
                    i5++;
                }
                else
                {
                    buff = buff + "null,";
                }

                if ((i10 < sma10.DDate.Count) && (sma10.DDate[i10] == dln.Ngay))
                {
                    buff = buff + sma10.FVals1[i10].ToString() + ",";
                    i10++;
                }
                else
                {
                    buff = buff + "null,";
                }

                if ((i20 < sma20.DDate.Count) && (sma20.DDate[i20] == dln.Ngay))
                {
                    buff = buff + sma20.FVals1[i20].ToString() + ",";
                    i20++;
                }
                else
                {
                    buff = buff + "null,";
                }

                if ((i50 < sma50.DDate.Count) && (sma50.DDate[i50] == dln.Ngay))
                {
                    buff = buff + sma50.FVals1[i50].ToString() + ",";
                    i50++;
                }
                else
                {
                    buff = buff + "null,";
                }

                if ((igSma5_20 < gSMA5_20.Gds1.Count) && (gSMA5_20.Gds1[igSma5_20] == dln.Ngay))
                {
                    buff = buff + gSMA5_20.G1[igSma5_20].ToString() + ",";
                    igSma5_20++;
                }
                else
                {
                    buff = buff + "null,";
                }

                if ((igSma10_50 < gSMA10_50.Gds1.Count) && (gSMA10_50.Gds1[igSma10_50] == dln.Ngay))
                {
                    buff = buff + gSMA10_50.G1[igSma10_50].ToString() + ",";
                    igSma10_50++;

                }
                else
                {
                    buff = buff + "null,";
                }

                if ((iCCI < Cci.Date.Count) && (Cci.Date[iCCI] == dln.Ngay))
                {
                    buff = buff + Cci.CCI1[iCCI].ToString();
                    iCCI++;

                }
                else
                {
                    buff = buff + "null";
                }

                sw.WriteLine(buff);

            }
            sw.Close();
        }
Example #20
0
 private void loadDataToDgv()
 {
     dgvDocGia.DataSource = BUS.xuat_DG();
 }
Example #21
0
 public int Create(BUS.Contact contact)
 {
     var dbContact = FromEntity(contact);
     DB.Contacts.InsertOnSubmit(dbContact);
     DB.SubmitChanges();
     return dbContact.Id;
 }
Example #22
0
 public FIFO_Data(FIFOChannel FIFO, BUS bus, bool IsLower) : base(bus, IsLower)
 {
     this.FIFO = FIFO;
 }
Example #23
0
 public cDMAAddressHalf(BUS bus, bool IsLower, ushort BitMask) : base(bus, IsLower)
 {
     this.AddressMask = BitMask;
 }
Example #24
0
 public Channel(int channelNumber, InterruptChannel interrupt, BUS bus)
 {
     this.channelNumber = channelNumber;
     this.interrupt     = interrupt;
     this.bus           = bus;
 }
Example #25
0
 public WriteOnlyRegister2(BUS bus, bool IsLower)
 {
     this.bus     = bus;
     this.IsLower = IsLower;
 }
Example #26
0
 public UnusedRegisterHalf(BUS bus, bool upper)
 {
     this.bus   = bus;
     this.upper = upper;
 }
Example #27
0
 private void btnCapNhat_Click(object sender, EventArgs e)
 {
     try
     {
         if (btnThem.Active)
         {
             QLThuVien.ValueObject.DocGia a = new QLThuVien.ValueObject.DocGia();
             a.MaDG     = txtmadg.Text.Trim();
             a.TenDG    = txtten.Text.Trim();
             a.NgaySinh = date1.Value;
             a.DiaChi   = txtdiachi.Text.Trim();
             a.SDT1     = txtsdt.Text.Trim();
             a.LoaiDG   = cbxloai.Text.Trim();
             if (rdbnam.Checked)
             {
                 a.GioiTinh = "Nam";
             }
             else if (rdbnu.Checked)
             {
                 a.GioiTinh = "Nữ";
             }
             if (a.MaDG == null || a.MaDG == "")
             {
                 throw new Exception();
             }
             if (BUS.them_DG(a) == 1)
             {
                 loadDataToDgv();
                 MessageBox.Show("Thêm Thành Công");
             }
             else
             {
                 throw new Exception();
             }
         }
         else if (btnSua.Active)
         {
             QLThuVien.ValueObject.DocGia a = new QLThuVien.ValueObject.DocGia();
             a.MaDG     = txtmadg.Text.Trim();
             a.TenDG    = txtten.Text.Trim();
             a.NgaySinh = date1.Value;
             a.DiaChi   = txtdiachi.Text.Trim();
             a.SDT1     = txtsdt.Text.Trim();
             a.LoaiDG   = cbxloai.Text.Trim();
             if (rdbnam.Checked)
             {
                 a.GioiTinh = "Nam";
             }
             else if (rdbnu.Checked)
             {
                 a.GioiTinh = "Nữ";
             }
             if (a.MaDG == null || a.MaDG == "")
             {
                 throw new Exception();
             }
             if (BUS.sua_DG(a) == 1)
             {
                 loadDataToDgv();
                 MessageBox.Show("Sửa Thành Công");
             }
             else
             {
                 throw new Exception();
             }
         }
     }
     catch
     {
         MessageBox.Show("Input sai");
     }
     finally
     {
         clearInput();
         disableInput();
         btnXoa.Active   = true;
         btnThem.Enabled = true;
         btnSua.Enabled  = false;
         btnXoa.Text     = "Xóa";
     }
 }
Example #28
0
        public int Create(BUS.Contact contact)
        {
            var id = GetContacts().Count > 0 ?  this.GetContacts().Max(c => c.Id) + 1 : 1;
            contact.Id = id;
            var doc = this.GetDocument();
            doc.Element("Contacts").Add(ToXElement(contact));
            doc.Save(GetPath());

            return id;
        }
Example #29
0
 public void Delete(BUS.Contact contact)
 {
     var doc = GetDocument();
     var nodeToDelete = doc.Descendants("Contact").Where(node => (int)node.Element("Id") == contact.Id).SingleOrDefault();
     nodeToDelete.Remove();
     doc.Save(GetPath());
 }
Example #30
0
 public void Edit(BUS.Contact contact)
 {
     var doc = GetDocument();
     var nodeToEdit = doc.Descendants("Contact").Where(node => (int)node.Element("Id") == contact.Id).SingleOrDefault();
     nodeToEdit.ReplaceWith(ToXElement(contact));
     doc.Save(GetPath());
 }
        protected void AddProductButton_Click(object sender, EventArgs e)
        {
            List<string> image_name = new List<string>();
            String path = Server.MapPath("~/style/image/");
            image_name = get_list_file_upload();
            for (int i = 0; i < image_name.Count; i++)
            {
                try
                {
                    if (ProductImage1.FileName == image_name[i].ToString())
                    {
                        ProductImage1.PostedFile.SaveAs(path + ProductImage1.FileName);
                    }
                    if (ProductImage2.FileName == image_name[i].ToString())
                    {
                        ProductImage2.PostedFile.SaveAs(path + ProductImage2.FileName);
                    }
                    if (ProductImage3.FileName == image_name[i].ToString())
                    {
                        ProductImage3.PostedFile.SaveAs(path + ProductImage3.FileName);
                    }
                    if (ProductImage4.FileName == image_name[i].ToString())
                    {
                        ProductImage4.PostedFile.SaveAs(path + ProductImage4.FileName);
                    }
                }
                catch (Exception ex)
                {
                    LabelAddStatus.Text = ex.Message;
                }
            }
            List<string> cat_id = new List<string>();
            foreach (ListItem item in addProductInCategory.Items)
            {
                if (item.Selected)
                {
                    cat_id.Add(item.Value);
                }
            }
            bool addSuccess;
            BUS products = new BUS();

            addSuccess = products.AddProduct(AddProductName.Text, AddProductDescription.Text, AddProductDetail.Text,
                AddProductPrice.Text, AddProductReview.Text, 1, AddProductGift.Text,
                AddProductsale.Text, AddProductVendor.Text, AddProductOnsale.Checked, AddProductOldPrice.Text,
                image_name[0].ToString(), image_name[1].ToString(), image_name[2].ToString(), image_name[3].ToString(), Show.Checked, cat_id);

            if (addSuccess)
            {
                // Reload the page.
                string pageUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.Count() - Request.Url.Query.Count());
                Response.Redirect(pageUrl + "?ProductAction=add");
            }
            else
            {
                LabelAddStatus.Text = "Không thể thêm sản phẩm vào cơ sở dữ liệu.";
            }
        }
Example #32
0
 public UnusedRegister(BUS bus)
 {
     this.lower = new UnusedRegisterHalf(bus, false);
     this.upper = new UnusedRegisterHalf(bus, true);
 }
Example #33
0
        //Xac nhan
        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            try
            {
                //khoi tao TS
                QLThuVien.ValueObject.TuaSach ts = new QLThuVien.ValueObject.TuaSach();
                ts.MaTS      = txtMTS.Text.Trim();
                ts.TenTS     = txtTS.Text.Trim();
                ts.NamXB     = int.Parse(txtNamXB.Text);
                ts.ViTri     = txtVT.Text.Trim();
                ts.NoiDungTT = txtNDTT.Text.Trim();
                ts.NnChinh   = txtNN.Text.Trim();
                ts.MaNXB     = null;
                foreach (DataRow row in dtNXB.Rows)
                {
                    if (cbbNXB.Text == Convert.ToString(row.ItemArray[1]))
                    {
                        ts.MaNXB = Convert.ToString(row.ItemArray[0]);
                        break;
                    }
                }

                if (btnThem.Active)
                {
                    ts.Gia1 = int.Parse(txtGia.Text);
                    //them TS
                    if (ts.MaNXB == null || ts.MaTS == "")
                    {
                        throw new Exception();
                    }

                    if (BUS.them_TS(ts) > 0)
                    {
                        updateDataToDgv();
                    }
                    else
                    {
                        throw new Exception();
                    }

                    //them TL_TS
                    if (ChonTL.maTL != null)
                    {
                        string[] strTL = ChonTL.maTL.Split(';');
                        QLThuVien.ValueObject.TS_TL tstl = new QLThuVien.ValueObject.TS_TL();
                        tstl.MaTS = ts.MaTS;
                        foreach (string str in strTL)
                        {
                            tstl.MaTL = str;
                            BUS.them_TSTL(tstl);
                        }
                    }

                    //them Viet
                    if (ChonTG.maTG != null)
                    {
                        string[] strTG = ChonTG.maTG.Split(';');
                        QLThuVien.ValueObject.Viet viet = new QLThuVien.ValueObject.Viet();
                        viet.MaTS = ts.MaTS;
                        foreach (string str in strTG)
                        {
                            viet.MaTG = str;
                            BUS.them_V(viet);
                        }
                    }

                    MessageBox.Show("Thêm thành công");
                }
                else if (btnSua.Active)
                {
                    ts.Gia1 = int.Parse(txtGia.Text.Split('.')[0]);
                    //sua TS
                    if (ts.MaNXB == null || ts.MaTS == "")
                    {
                        throw new Exception();
                    }

                    if (BUS.sua_TS(ts) > 0)
                    {
                        updateDataToDgv();
                    }
                    else
                    {
                        throw new Exception();
                    }

                    //sua TLTS
                    if (ChonTL.maTL != null)
                    {
                        string[] strTL = ChonTL.maTL.Split(';');
                        QLThuVien.ValueObject.TS_TL tstl = new QLThuVien.ValueObject.TS_TL();
                        tstl.MaTS = ts.MaTS;
                        foreach (string str in strTL)
                        {
                            if (str != "")
                            {
                                if (maTLcu == null || !maTLcu.Contains(str))
                                {
                                    tstl.MaTL = str;
                                    BUS.them_TSTL(tstl);
                                }
                            }
                        }
                    }
                    if (maTLcu != null)
                    {
                        string[] strTL = maTLcu.Split(';');
                        foreach (string str in strTL)
                        {
                            if (str != "")
                            {
                                if (ChonTL.maTL == null || !ChonTL.maTL.Contains(str))
                                {
                                    BUS.xoa_TSTL(ts.MaTS, str);
                                }
                            }
                        }
                    }

                    //sua viet
                    if (ChonTG.maTG != null)
                    {
                        string[] strTG = ChonTG.maTG.Split(';');
                        QLThuVien.ValueObject.Viet viet = new QLThuVien.ValueObject.Viet();
                        viet.MaTS = ts.MaTS;
                        foreach (string str in strTG)
                        {
                            if (str != "")
                            {
                                if (maTGcu == null || !maTGcu.Contains(str))
                                {
                                    viet.MaTG = str;
                                    BUS.them_V(viet);
                                }
                            }
                        }
                    }
                    if (maTGcu != null)
                    {
                        string[] strTG = maTGcu.Split(';');
                        foreach (string str in strTG)
                        {
                            if (str != "")
                            {
                                if (ChonTG.maTG == null || !ChonTG.maTG.Contains(str))
                                {
                                    BUS.xoa_V(ts.MaTS, str);
                                }
                            }
                        }
                    }
                    MessageBox.Show("Sửa thành công");
                }
            }
            catch
            {
                MessageBox.Show("Input sai");
            }
            finally
            {
                clearInput();
                disbleInput();
                btnXoa.Active   = true;
                btnThem.Enabled = true;
                btnSua.Enabled  = false;
                btnXoa.Text     = "Xóa";
            }
        }
Example #34
0
 public void Delete(BUS.Contact contact)
 {
     var toDelete = DB.Contacts.Where(c => c.Id == contact.Id);
     DB.Contacts.DeleteOnSubmit(toDelete.SingleOrDefault());
     DB.SubmitChanges();
 }
Example #35
0
 public cDMAAddress(BUS bus, bool InternalMemory) : base(
         new cDMAAddressHalf(bus, true, 0xffff),
         new cDMAAddressHalf(bus, false, (ushort)(InternalMemory ? 0x07ff : 0x0fff))
         )
 {
 }
Example #36
0
 private void loadtodgv()
 {
     dgvPB.DataSource = BUS.xuat_PB();
 }
        protected void EditProductButton_Click(object sender, EventArgs e)
        {
            String path = Server.MapPath("~/style/image/");
            List<string> tmp = new List<string>();
            for (int i = 0; i < image_name.Count; i++)
                tmp.Add(image_name[i].ToString());
            get_list_file_upload();

            try
            {
                if (tmp[0].ToString() != image_name[0].ToString())
                {
                    ProductImage1.PostedFile.SaveAs(path + ProductImage1.FileName);
                }
                if (tmp[1].ToString() != image_name[1].ToString())
                {
                    ProductImage2.PostedFile.SaveAs(path + ProductImage2.FileName);
                }
                if (tmp[2].ToString() != image_name[2].ToString())
                {
                    ProductImage3.PostedFile.SaveAs(path + ProductImage3.FileName);
                }
                if (tmp[3].ToString() != image_name[3].ToString())
                {
                    ProductImage4.PostedFile.SaveAs(path + ProductImage4.FileName);
                }
            }
            catch (Exception ex)
            {
                LabelAddStatus.Text = ex.Message;
            }

            List<string> cat_id = new List<string>();
            foreach (ListItem item in addProductInCategory.Items)
            {
                if (item.Selected)
                {
                    cat_id.Add(item.Value);
                }
            }

            BUS products = new BUS();

            //products.editProduct(p, AddProductName.Text, AddProductDescription.Text, AddProductDetail.Text,
            //AddProductPrice.Text, AddProductReview.Text, 1, AddProductGift.Text,
            //AddProductsale.Text, AddProductVendor.Text, AddProductOnsale.Checked, AddProductOldPrice.Text,
            //image_name[0].ToString(), image_name[1].ToString(), image_name[2].ToString(), image_name[3].ToString(), Show.Checked, cat_id);
            //db.SaveChanges();
            products.editProduct(p, AddProductName.Text, AddProductDescription.Text,"",
            AddProductPrice.Text, "", 1, "",
            "", AddProductVendor.Text, AddProductOnsale.Checked, AddProductOldPrice.Text,
            image_name[0].ToString(), image_name[1].ToString(), image_name[2].ToString(), image_name[3].ToString(), Show.Checked, cat_id);
            db.SaveChanges();

            string pageUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.Count() - Request.Url.Query.Count());
            Response.Redirect(pageUrl + "?ProductAction=edit");
        }
Example #38
0
 private void loadCTM()
 {
     dgvCTM.DataSource = BUS.xuat_CTMcuaPM(txtSoPMT.Text.Trim());
 }
Example #39
0
 public byte GetPins(BUS bus)
 {
     rawWrite(new byte[] { (byte)(bus + 1) });
     return(rawRead(1)[0]);
 }
Example #40
0
        private void WriteFileGuessCCI(BUS.CCI Cci)
        {
            TenFile = TenFile.Substring(0, TenFile.Length - 4);
            StreamWriter sw = new StreamWriter(TenFile + "_GuessCCI.txt");

            int count = 0;                              // nguong gia tri lua chon xu huong tang hay giam , co the dung cach xac dinh khac thay cho count
            for (int i = 0; i < Cci.MS1.Size - 1; i++)
            {
                if (Cci.CCI1[i] * Cci.CCI1[i + 1] <= 0)
                {
                    if (count > 3)
                    {
                        if (Cci.CCI1[i] > 0)
                        {
                            sw.WriteLine("-Tu ngay {0} den ngay {1} co xu huong tang", Cci.Date[i - count], Cci.Date[i]);
                        }
                        if (Cci.CCI1[i] < 0)
                        {
                            sw.WriteLine("-Tu ngay {0} den ngay {1} co xu huong giam", Cci.Date[i - count], Cci.Date[i]);
                        }
                    }
                    count = 0;
                }
                else
                {
                    count++;
                }
                if (Cci.CCI1[i] > 100)
                {
                    sw.WriteLine("-Thi truong ngay {0} di vao vung MUA QUA MUC", Cci.Date[i]);
                }
                if (Cci.CCI1[i] < -100)
                {
                    sw.WriteLine("-Thi truong ngay {0} di vao vung BAN QUA MUC", Cci.Date[i]);
                }
            }

            sw.Close();
        }
Example #41
0
 public void Edit(BUS.Contact contact)
 {
     //database.Contact toEdit = GetContact(contact.Id);
     database.Contact toEdit = DB.Contacts.Where(c => c.Id == contact.Id).SingleOrDefault();
     toEdit.FirstName = contact.FirstName;
     toEdit.LastName = contact.LastName;
     toEdit.Email = contact.Email;
     toEdit.LuckyNumber = contact.LuckyNumber;
     DB.SubmitChanges();
 }
Example #42
0
        //public static string connectionString = @"Data Source=DESKTOP-DC6275B\SQLEXPRESS;Initial Catalog=convinience_store;Integrated Security=True";

        //public DataTable searchProductName(string query, string name)
        //{
        //    DataTable data = new DataTable();
        //    using (SqlConnection connection = new SqlConnection(connectionString))
        //    {
        //        connection.Open();
        //        SqlCommand cmd = new SqlCommand(query, connection);
        //        cmd.Parameters.AddWithValue("@product_name", name);
        //        SqlDataAdapter adapter = new SqlDataAdapter(cmd);
        //        adapter.Fill(data);
        //        connection.Close();
        //    }
        //    return data;
        //}

        private void button1_Click(object sender, EventArgs e)
        {
            BUS bus = new BUS();

            dataGridView1.DataSource = bus.searchProductName(textBox1.Text);
        }
Example #43
0
 private void loadPMT()
 {
     dgvPMT.DataSource = BUS.xuat_PMTcuaDG(txtMDG1.Text.Trim());
 }
Example #44
0
 public WriteOnlyLCDRegister2(PPU ppu, BUS bus, bool IsLower) : base(ppu)
 {
     this.bus     = bus;
     this.IsLower = IsLower;
 }