private void buttonOk_Click(object sender, EventArgs e)
        {
            if (!superValidator1.Validate())
                return;
            try
            {
                if (UserAction == "edit")
                {
                    ServiceDetail.ServiceName = textBoxServiceName.Text;
                    ServiceDetail.Price = decimal.Parse(textBoxPrice.Text);
                    DialogResult dialogResult = MessageBox.Show("Xác nhận cập nhập thông tin dịch vụ", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dialogResult == DialogResult.Yes)
                    {
                        if (Service.UpdateService(ServiceDetail) > 0)
                            MessageBox.Show("Cập nhập dịch vụ thành công thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                }
                else
                {
                    Service newService = new Service(0, textBoxServiceName.Text, decimal.Parse(textBoxPrice.Text));
                    if (Service.InsertService(newService) > 0)
                        MessageBox.Show("Thêm dịch vụ thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch
            {
                MessageBox.Show("Lỗi dữ liệu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            this.Close();
        }
Exemple #2
0
 public static int InsertService(Service newService)
 {
     String sqlInsert = @"INSERT INTO SERVICE(SERVICENAME, PRICE)
                         VALUES        (@SERVICENAME,@PRICE)";
     SqlParameter[] sqlParameters = { new SqlParameter("@SERVICENAME", newService.ServiceName),
                                    new SqlParameter("@PRICE",newService.Price)};
     return SqlResult.ExecuteNonQuery(sqlInsert, sqlParameters);
 }
 public FormServiceDetail(Service serviceDetail, String userAction)
 {
     InitializeComponent();
     this.ServiceDetail = serviceDetail;
     this.UserAction = userAction;
     if (this.UserAction == "edit")
         SetServiceDetail(serviceDetail);
 }
Exemple #4
0
 public static int UpdateService(Service updateService)
 {
     string sqlUpdate = @"UPDATE       SERVICE
                         SET                SERVICENAME = @SERVICENAME, PRICE = @PRICE
                         WHERE         SERVICEID=@SERVICEID";
     SqlParameter[] sqlParameters = { new SqlParameter("@SERVICEID", updateService.ServiceID),
                                     new SqlParameter("@SERVICENAME", updateService.ServiceName),
                                    new SqlParameter("@PRICE", updateService.Price)};
     return SqlResult.ExecuteNonQuery(sqlUpdate, sqlParameters);
 }
Exemple #5
0
        public static Service GetServiceExamination()
        {
            Service newService = new Service();
            int tempInterger;
            string sqlSelect = @"SELECT        SERVICEID, SERVICENAME, PRICE
                                FROM            SERVICE
                                WHERE        SERVICEID=100";
 
            DataTable dataTable = SqlResult.ExecuteQuery(sqlSelect);
            if (dataTable.Rows.Count > 0)
            {
                int.TryParse(dataTable.Rows[0][0].ToString(), out tempInterger);
                newService.ServiceID = tempInterger;
                newService.ServiceName = dataTable.Rows[0][1].ToString();
                newService.Price = (decimal)dataTable.Rows[0][2];
            }
            return newService;
        }
Exemple #6
0
 public static Service GetService(int serviceID)
 {
     Service newService = new Service();
     int tempInterger;
     string sqlSelect = @"SELECT        SERVICEID, SERVICENAME, PRICE
                         FROM            SERVICE
                         WHERE        SERVICEID=@SERVICEID";
     SqlParameter[] sqlParameters = { new SqlParameter("@SERVICEID", serviceID) };
     DataTable dataTable = SqlResult.ExecuteQuery(sqlSelect,sqlParameters);
     if (dataTable.Rows.Count > 0)
     {
         int.TryParse(dataTable.Rows[0][0].ToString(), out tempInterger);
         newService.ServiceID = tempInterger;
         newService.ServiceName = dataTable.Rows[0][1].ToString();
         newService.Price = (decimal)dataTable.Rows[0][2];
     }
     return newService;
 }
 private void SetServiceDetail(Service serviceDetail)
 {
     textBoxServiceID.Text = ServiceDetail.ServiceID.ToString();
     textBoxServiceName.Text = ServiceDetail.ServiceName;
     textBoxPrice.Text = Convert.ToInt64(ServiceDetail.Price).ToString();
 }