public QuanAn update(QuanAn QuanAn)
        {
            string query = string.Format("update QuanAn set name = @name, timeOpen = @timeOpen, timeClose = @timeClose, typeFood = @typeFood, phone = @phone, address = @address where ID = @id");

            SqlParameter[] sqlParameters = new SqlParameter[7];

            sqlParameters[0]       = new SqlParameter("@name", SqlDbType.NVarChar);
            sqlParameters[0].Value = QuanAn.name;
            sqlParameters[1]       = new SqlParameter("@timeOpen", SqlDbType.NVarChar);
            sqlParameters[1].Value = QuanAn.timeOpen;
            sqlParameters[2]       = new SqlParameter("@timeClose", SqlDbType.NVarChar);
            sqlParameters[2].Value = QuanAn.timeClose;
            sqlParameters[3]       = new SqlParameter("@typeFood", SqlDbType.NVarChar);
            sqlParameters[3].Value = QuanAn.typeFood;
            sqlParameters[4]       = new SqlParameter("@phone", SqlDbType.NVarChar);
            sqlParameters[4].Value = QuanAn.phoneContact;
            sqlParameters[5]       = new SqlParameter("@address", SqlDbType.NVarChar);
            sqlParameters[5].Value = QuanAn.address;
            sqlParameters[6]       = new SqlParameter("@ID", SqlDbType.Int);
            sqlParameters[6].Value = QuanAn.ID;
            var rs = conn.executeUpdateQuery(query, sqlParameters);

            if (!rs)
            {
                return(null);
            }
            return(QuanAn);
        }
Exemplo n.º 2
0
        public static QuanAn Get_Node_Data(int index, string key)
        {
            QuanAn    QA  = new QuanAn();
            XDocument doc = new XDocument();

            doc = XDocument.Load(Path_Data);
            var Elements = from element in doc.Elements("QLQA").Elements("QUANAN")
                           where element.Attribute("Quan").Value == key
                           select element;
            int dem = -1;

            foreach (var node in Elements)
            {
                dem++;
                if (dem == index)
                {
                    QA.Ten           = node.Attribute("Ten").Value;
                    QA.DiaDiem.Duong = node.Attribute("Duong").Value;
                    QA.SoBan         = Convert.ToInt32(node.Attribute("Soban").Value);
                    QA.DiaDiem.Quan  = key;
                    break;
                }
            }
            return(QA);
        }
        public QuanAn saveOne(QuanAn QuanAn)
        {
            string query = string.Format("insert into QuanAn values(@name, @timeOpen, @timeClose, @typeFood, @phone, @address)");

            SqlParameter[] sqlParameters = new SqlParameter[6];
            sqlParameters[0]       = new SqlParameter("@name", SqlDbType.NVarChar);
            sqlParameters[0].Value = QuanAn.name;
            sqlParameters[1]       = new SqlParameter("@timeOpen", SqlDbType.NVarChar);
            sqlParameters[1].Value = QuanAn.timeOpen;
            sqlParameters[2]       = new SqlParameter("@timeClose", SqlDbType.NVarChar);
            sqlParameters[2].Value = QuanAn.timeClose;
            sqlParameters[3]       = new SqlParameter("@typeFood", SqlDbType.NVarChar);
            sqlParameters[3].Value = QuanAn.typeFood;
            sqlParameters[4]       = new SqlParameter("@phone", SqlDbType.NVarChar);
            sqlParameters[4].Value = QuanAn.phoneContact;
            sqlParameters[5]       = new SqlParameter("@address", SqlDbType.NVarChar);
            sqlParameters[5].Value = QuanAn.address;
            var rs = conn.executeInsertQuery(query, sqlParameters);

            if (!rs)
            {
                return(null);
            }
            return(QuanAn);
        }
Exemplo n.º 4
0
 public DataTable deleteRestaurant(QuanAn qa)
 {
     try
     {
         qlRepo.delete(qa);
         return(getAllRestaurant());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 5
0
 public DataTable addRestaurent(QuanAn qa)
 {
     try
     {
         qlRepo.saveOne(qa);
         return(getAllRestaurant());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        private void Btn_Add_Click(object sender, RoutedEventArgs e)
        {
            QuanAn temp = new QuanAn();

            temp.Ten     = Text_Ten.Text;
            temp.DiaDiem = new Diadiem()
            {
                Duong = Text_Duong.Text, Quan = Quan
            };
            temp.SoBan   = Convert.ToInt32(Text_Soban.Text);
            qa           = temp;
            DialogResult = true;
            Close();
        }
Exemplo n.º 7
0
        public static void Add_Node_Data(QuanAn QA)
        {
            XDocument doc = new XDocument();

            doc = XDocument.Load(Path_Data);
            XElement node = doc.Element("QLQA");
            XElement Quan = new XElement("QUANAN",
                                         new XAttribute("Ten", QA.Ten),
                                         new XAttribute("Duong", QA.DiaDiem.Duong),
                                         new XAttribute("Quan", QA.DiaDiem.Quan),
                                         new XAttribute("Soban", QA.SoBan));

            node.Add(Quan);
            doc.Save(Path_Data);
        }
        public QuanAn delete(QuanAn QuanAn)
        {
            string query = string.Format("delete from QuanAn where ID = @id");

            SqlParameter[] sqlParameters = new SqlParameter[1];
            sqlParameters[0]       = new SqlParameter("@id", SqlDbType.Int);
            sqlParameters[0].Value = QuanAn.ID;
            var rs = conn.executeInsertQuery(query, sqlParameters);

            if (!rs)
            {
                return(null);
            }
            return(QuanAn);
        }
Exemplo n.º 9
0
        private void btnAddorEdit_Click(object sender, EventArgs e)
        {
            var qa = new QuanAn(txtNameRestaurant.Text, txtTimeOpen.Text, txtTimeClose.Text, txtTypeFood.Text, txtPhone.Text, txtAddress.Text);

            if (btnAddorEdit.Text == "Edit")
            {
                qa.ID = int.Parse(txtID.Text);
                grvQuanLy.DataSource = quanAnBus.updateRestaurent(qa);
                UpdateView("", "", "", "", "", "", "", "Add");
            }
            else
            {
                grvQuanLy.DataSource = quanAnBus.addRestaurent(qa);
            }
        }
Exemplo n.º 10
0
        private void Btn_Update_Click(object sender, RoutedEventArgs e)
        {
            OtherWork OW = new OtherWork();
            QuanAn    QA = new QuanAn();

            QA = DataXML.Get_Node_Data(List_Quan.SelectedIndex, (string)Cb_Quan.SelectedItem);
            OW.SetValue(QA);
            if (OW.ShowDialog() == true)
            {
                DataXML.Update_Data(QA, OW.NewValue);
                MessageBox.Show("Cập nhật quán thành công!", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information);
                Set_Result_ListView((string)Cb_Quan.SelectedItem);
            }
            else
            {
                MessageBox.Show("Cập nhật quán không thành công!", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Exemplo n.º 11
0
        public static void Update_Data(QuanAn Old, QuanAn New)
        {
            XDocument doc = new XDocument();

            doc = XDocument.Load(Path_Data);
            var Elements = from element in doc.Elements("QLQA").Elements("QUANAN")
                           where element.Attribute("Ten").Value == Old.Ten &&
                           element.Attribute("Duong").Value == Old.DiaDiem.Duong &&
                           element.Attribute("Quan").Value == Old.DiaDiem.Quan &&
                           Convert.ToInt32(element.Attribute("Soban").Value) == Old.SoBan
                           select element;

            foreach (var node in Elements)
            {
                node.SetAttributeValue("Ten", New.Ten);
                node.SetAttributeValue("Duong", New.DiaDiem.Duong);
                node.SetAttributeValue("Soban", New.SoBan);
                break;
            }
            doc.Save(Path_Data);
        }
Exemplo n.º 12
0
        public static List <QuanAn> Read_QuanAn_XML(string key)
        {
            List <QuanAn> Temp = new List <QuanAn>();
            XDocument     doc  = new XDocument();

            doc = XDocument.Load(Path_Data);
            var Elements = from element in doc.Elements("QLQA").Elements("QUANAN")
                           where element.Attribute("Quan").Value == key
                           select element;

            foreach (var node in Elements)
            {
                QuanAn QA = new QuanAn();
                QA.Ten     = node.Attribute("Ten").Value;
                QA.DiaDiem = new Diadiem()
                {
                    Duong = node.Attribute("Duong").Value, Quan = node.Attribute("Quan").Value
                };
                Temp.Add(QA);
            }
            return(Temp);
        }
 public void SetValue(QuanAn QA)
 {
     Text_Ten.Text   = QA.Ten;
     Text_Duong.Text = QA.DiaDiem.Duong;
     Text_Soban.Text = QA.SoBan.ToString();
 }