Exemplo n.º 1
0
        public void btnDeleteService_Click(object sender, EventArgs e)
        {
            try
            {
                Service_DTO service = new Service_DTO();
                service.ServiceID   = dtgvServiceInfoList.CurrentRow.Cells["ServiceID"].Value.ToString();
                service.ServiceName = txtServiceName.Text;

                if (txtServiceID.Text == "" || txtServiceName.Text == "" || txtServicePrice.Text == "")
                {
                    XtraMessageBox.Show("You have to choose at least one service to delete!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    ClearDisplay();
                    return;
                }

                if (Service_BUS.DeleteService(service))
                {
                    LoadServiceList();
                    XtraMessageBox.Show("Service Info has been deleted sucessfully!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ClearDisplay();
                    return;
                }
            }
            catch
            {
                XtraMessageBox.Show("Delete Info Failed!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Exemplo n.º 2
0
        //@Description:
        //      Chỉnh sửa 1 dịch vụ bằng id
        //@Parameter
        //    Service_DTO Service  --------Tham số nhập là 1 dịch vụ
        //    int id           -------- Mã dịch vụ
        //@Proc:
        //
        //@Return:
        //    boolean  ------------Thành công trả về true, thất bại trả về false;
        public bool Edit_Service(Service_DTO service)
        {
            string query = "exec USP_EditService @id_service , @name_service , @price , @unit";
            int    x     = Connect.Instance.ExecuteNonQuery(query, new object[] { service.Id_service, service.Name_service, service.Price, service.Unit });

            return(x == 1);
        }
Exemplo n.º 3
0
        public static List <Service_DTO> LoadService()
        {
            List <Service_DTO> listService = new List <Service_DTO>();
            SqlConnection      con         = DataProvider.OpenConnection();

            SqlCommand cmd = new SqlCommand("[JEWELRYSTOREMGMT].[dbo].[usp_getServiceList]", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.ExecuteNonQuery();

            SqlDataAdapter da = new SqlDataAdapter();

            da.SelectCommand = cmd;
            DataTable dt = new DataTable();

            da.Fill(dt);

            if (dt.Rows.Count == 0)
            {
                return(null);
            }

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                Service_DTO service = new Service_DTO();
                service.ServiceID    = dt.Rows[i]["ServiceID"].ToString();
                service.ServiceName  = dt.Rows[i]["ServiceName"].ToString();
                service.ServicePrice = float.Parse(dt.Rows[i]["ServicePrice"].ToString());

                listService.Add(service);
            }
            DataProvider.CloseConnection(con);

            return(listService);
        }
        private async void btn_enable_Click(object sender, RoutedEventArgs e)
        {
            progress_bar.Visibility  = Visibility.Visible;
            progress_bar2.Visibility = Visibility.Visible;

            DataGridCellInfo temp    = list_servicenotactive.SelectedCells[0];
            Service_DTO      service = temp.Item as Service_DTO;

            string outlet_name = cb_outlet.SelectedItem.ToString();
            int    outlet_id   = -1;

            foreach (Outlet_DTO temp1 in list)
            {
                if (temp1.outlet_name == outlet_name)
                {
                    outlet_id = temp1.outlet_id;
                    break;
                }
            }

            DeactiveRequest deactive = new DeactiveRequest();

            deactive.service_id = service.service_id;
            deactive.outlet_id  = outlet_id;

            bool result = await RestAPI.PostServiceHandle(deactive, "active");

            Start_State(cb_outlet.SelectedIndex);
        }
Exemplo n.º 5
0
        public static bool UpdateService(Service_DTO service)
        {
            SqlConnection con = DataProvider.OpenConnection();
            SqlCommand    cmd = new SqlCommand("[JEWELRYSTOREMGMT].[dbo].[usp_updateService]", con);

            try
            {
                cmd.CommandType = CommandType.StoredProcedure;
                SqlParameter p = new SqlParameter("@ServiceID", service.ServiceID);
                cmd.Parameters.Add(p);
                p = new SqlParameter("@ServiceName", service.ServiceName);
                cmd.Parameters.Add(p);
                p = new SqlParameter("@ServicePrice", service.ServicePrice);
                cmd.Parameters.Add(p);

                cmd.ExecuteNonQuery();
                DataProvider.CloseConnection(con);
                return(true);
            }
            catch
            {
                DataProvider.CloseConnection(con);
                return(false);
            }
        }
Exemplo n.º 6
0
        private void btnAddService_Click(object sender, EventArgs e)
        {
            try
            {
                Service_DTO service = new Service_DTO();
                service.ServiceID    = txtServiceID.Text;
                service.ServiceName  = txtServiceName.Text;
                service.ServicePrice = float.Parse(txtServicePrice.Text);

                if (txtServiceID.Text == "" || txtServiceName.Text == "" || txtServicePrice.Text == "")
                {
                    XtraMessageBox.Show("You have to fullfill service information!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    ClearDisplay();
                    return;
                }

                if (Service_BUS.InsertService(service))
                {
                    XtraMessageBox.Show("Service Info has been inserted sucessfully!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadServiceList();
                    ClearDisplay();
                    return;
                }
            }
            catch
            {
                XtraMessageBox.Show("Insert Info Failed!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Exemplo n.º 7
0
        //@Description:
        //      Thêm vào 1 dịch vụ
        //@Parameter
        //    Service_DTO Service  --------Tham số nhập là 1 dịch vụ
        //@Proc:
        //
        //@Return:
        //    boolean  ------------Thành công trả về true, thất bại trả về false;
        public bool Add_Service(Service_DTO service)
        {
            string query = "exec USP_InsertService @name_service , @price , @unit";// exec USP_InsertStuff @name = value , @price = value , @unit =value
            int    x     = Connect.Instance.ExecuteNonQuery(query, new object[] { service.Name_service, service.Price, service.Unit });

            return(x == 1);
        }
Exemplo n.º 8
0
        public static async Task <Service_DTO> GetServiceDetail(string service_id)
        {
            Service_DTO service = new Service_DTO();

            string api = "/api/service/" + service_id;

            try
            {
                HttpClient client = new HttpClient();

                client = RestAPI.Get_HttpClient_Token();

                var response = new HttpResponseMessage();

                response = await client.GetAsync(api).ConfigureAwait(false);

                if (response.IsSuccessStatusCode)
                {
                    var result = response.Content.ReadAsStringAsync().Result;
                    service = JsonConvert.DeserializeObject <Service_DTO>(result);

                    response.Dispose();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(service);
        }
        private void list_serviceactive_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            DataGridCellInfo temp = list_serviceactive.SelectedCells[0];

            Service_DTO service = temp.Item as Service_DTO;

            MessageBox.Show(service.service_name);
        }
Exemplo n.º 10
0
        private void fEdit_Service_Load(object sender, EventArgs e)
        {
            Service_DTO service_info = Service_BUS.Instance.Get_Info(this.Id_service);

            txt_1.Text = service_info.Name_service;
            txt_2.Text = service_info.Price.ToString();
            txt_3.Text = service_info.Unit;
        }
Exemplo n.º 11
0
 //@Description:
 //      Bắt lỗi hàm Thêm vào 1 dịch vụ
 //@Parameter
 //    Service_DTO Service  --------Tham số nhập là 1 dịch vụ
 //@Proc:
 //
 //@Call:
 //      Service_DAO.Instance.Add_Service(service);
 //@Return:
 //    boolean  ------------Thành công trả về true, thất bại trả về false;
 public bool Add_Service(Service_DTO service)
 {
     try
     {
         return(Service_DAO.Instance.Add_Service(service));
     }
     catch
     {
         throw new Exception("Error!");
     }
 }
Exemplo n.º 12
0
        //@Description:
        //      Lấy ra thông tin của dịch vụ bằng id
        //@Parameter
        //    string id_Service
        //@Proc:
        //
        //@Return:
        //    Service_DTO  --- Trả về 1 dịch vụ
        public Service_DTO Get_Info(int id_service)
        {
            string      query   = "exec USP_GetInfoService @id_service";
            DataTable   table   = Connect.Instance.ExecuteQuery(query, new object[] { id_service });
            Service_DTO service = null;

            foreach (DataRow item in table.Rows)
            {
                service = new Service_DTO(item);
            }
            return(service);
        }
Exemplo n.º 13
0
        private Service_DTO Set_Service()
        {
            Service_DTO ser = new Service_DTO();

            if (this.id_service != 0)
            {
                ser.Id_service = this.Id_service;
            }
            ser.Name_service = txt_1.Text;
            ser.Price        = decimal.Parse(txt_2.Text);
            ser.Unit         = txt_3.Text;
            return(ser);
        }
Exemplo n.º 14
0
        //@Description:
        //     Tìm kiếm dịch vụ
        //@Parameter
        //    String keyword
        //    int type_search   ------- tìm kiếm theo mã hay tên, (bên dưới là chú thích loại tìm kiếm)
        //@Proc:
        //
        //@Call:
        //    this.Del_Service(int id)
        //@Return:
        //    List<Service_DTO>   ------------ Trả về danh sách thỏa mãn
        public List <Service_DTO> Search_Service(String keyword, int type)
        {
            string             query        = "exec USP_SearchService @keyword , @type";
            DataTable          table        = Connect.Instance.ExecuteQuery(query, new object[] { keyword, type });
            List <Service_DTO> list_Service = new List <Service_DTO>();

            foreach (DataRow item in table.Rows)
            {
                Service_DTO service = new Service_DTO(item);
                list_Service.Add(service);
            }
            return(list_Service);
        }
Exemplo n.º 15
0
        //@Description:
        //      Lấy ra danh sách dịch vụ trong bảng
        //@Parameter
        //    nope
        //@Proc:
        //
        //@Return:
        //    List<Service_DTO>  --- Trả về 1 danh sách các dịch vụ
        public List <Service_DTO> Get_List()
        {
            string             query        = "exec USP_GetListService";
            DataTable          table        = Connect.Instance.ExecuteQuery(query);
            List <Service_DTO> list_service = new List <Service_DTO>();

            foreach (DataRow item in table.Rows)
            {
                Service_DTO service = new Service_DTO(item);
                list_service.Add(service);
            }
            return(list_service);
        }
Exemplo n.º 16
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            bool flat = true;

            if (txt_nameservice.Text == "")
            {
                lb_error_name.Text = "The \"Username\" is not empty";
                flat = false;
            }
            if (txt_price.Text == "")
            {
                lb_error_price.Text = "The \"Price\" is not empty";
                flat = false;
            }

            if (txt_unit.Text == "")
            {
                lb_error_unit.Text = "The \"Unit\" is not empty";
                flat = false;
            }


            if (flat == true)
            {
                Service_DTO service = new Service_DTO();
                service.Name_service = txt_nameservice.Text;
                service.Price        = decimal.Parse(txt_price.Text);
                service.Unit         = txt_unit.Text;
                if (Service_BUS.Instance.Add_Service(service))
                {
                    MessageBox.Show("Add Successful");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("False");
                }
            }
        }
Exemplo n.º 17
0
        public static bool DeleteService(Service_DTO service)
        {
            SqlConnection con = DataProvider.OpenConnection();
            SqlCommand    cmd = new SqlCommand("[JEWELRYSTOREMGMT].[dbo].[usp_deleteService]", con);

            try
            {
                cmd.CommandType = CommandType.StoredProcedure;
                SqlParameter p = new SqlParameter("@ServiceID", service.ServiceID);
                cmd.Parameters.Add(p);

                cmd.ExecuteNonQuery();
                DataProvider.CloseConnection(con);
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DataProvider.CloseConnection(con);
                return(false);
            }
        }
Exemplo n.º 18
0
 public static bool InsertService(Service_DTO service)
 {
     return(Service_DAL.InsertService(service));
 }
Exemplo n.º 19
0
 public static bool DeleteService(Service_DTO service)
 {
     return(Service_DAL.DeleteService(service));
 }
Exemplo n.º 20
0
 public static bool UpdateService(Service_DTO service)
 {
     return(Service_DAL.UpdateService(service));
 }