Esempio n. 1
0
        /// <summary>
        /// Phương thức cập nhật một Services xuống csdl theo id
        /// </summary>
        /// <returns>true: thêm mới thành công, false: thêm mới thất bại</returns>
        public bool UpdateServices(DTOServices Services)
        {
            try
            {
                DataExecute.Instance.createSqlCmd("sp_EditServicesUpdate"/*Truyen vao storeprocedure*/, new object[5] { Services.ServicesID, Services.ServicesName, Services.ServicesTypeID, Services.Price, Services.UnitID });
                return DataExecute.Instance.updateData(DataConnection.Instance.m_cmd) > 0;
            }
            catch (SqlException)
            {

                throw;
            }
        }
Esempio n. 2
0
        private void SaveDataToDatabase()
        {
            if (!checkData())
            {
                return;
            }
            try
            {
                if (m_IsAdd)
                {
                    String servicesName = Utils.standardNamePerson(txtServicesName.Text);
                    String servicesType = lkServicesType.EditValue.ToString();
                    String unit = lkUnit.EditValue.ToString();
                    int price = Int32.Parse(spPrice.Value.ToString());

                    servicesObject = new DTOServices("DV00000000", servicesName, servicesType, unit, price);

                    if (servicesBUS.InsertServices(servicesObject))
                    {
                        XtraCustomMessageBox.Show("Thêm dữ liệu thành công!", "Thông báo", true, 1);
                    }
                    else
                    {
                        XtraCustomMessageBox.Show("Thêm dữ liệu thất bại!", "Lỗi", true, 4);
                    }
                }
                else
                {
                    String servicesName = Utils.standardNamePerson(txtServicesName.Text);
                    String servicesType = lkServicesType.EditValue.ToString();
                    String unit = lkUnit.EditValue.ToString();
                    int price = Int32.Parse(spPrice.Value.ToString());

                    servicesObject = new DTOServices(txtServicesId.Text, servicesName, servicesType, unit, price);

                    if (servicesBUS.UpdateServices(servicesObject))
                    {
                        XtraCustomMessageBox.Show("Cập nhật dữ liệu thành công!", "Thông báo", true, 1);
                    }
                    else
                    {
                        XtraCustomMessageBox.Show("Cập nhật dữ liệu thất bại!", "Lỗi", true, 4);
                    }
                }

            }
            catch (System.Exception ex)
            {
                XtraCustomMessageBox.Show(ex.ToString(), "Lỗi", true, 3);
            }
            finally
            {
                updateEnableButtonAndResetValueOfControl(ref btnSave);
            }
        }
Esempio n. 3
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (servicesMulitiSelect.Selection.Count == 0)
     {
         XtraCustomMessageBox.Show("Chưa có dòng dữ liệu nào được chọn!", "Thông báo", true, 1);
         return;
     }
     try
     {
         System.Collections.ArrayList _listservicesObjectInDelibility = new System.Collections.ArrayList();
         foreach (object _rowObjectItem in servicesMulitiSelect.Selection)
         {
             grdvListServices.FocusedRowHandle -= 1;
             DataRowView _rowObjectDetail = _rowObjectItem as DataRowView;
             servicesObject = new DTOServices(_rowObjectDetail.Row["ServicesID"].ToString(), _rowObjectDetail.Row["ServicesName"].ToString(), _rowObjectDetail.Row["ServicesTypeID"].ToString(), _rowObjectDetail.Row["UnitID"].ToString(), Int32.Parse(_rowObjectDetail.Row["Price"].ToString()));
             if (!servicesBUS.DeleteServices(servicesObject.ServicesID))
             {
                 _listservicesObjectInDelibility.Add(_rowObjectDetail.Row["ServicesID"]);
             }
         }
         String _erroContent = "Không thể xóa thông tin các thế loại sách có mã số: \n";
         if (_listservicesObjectInDelibility.Count != 0)
         {
             foreach (var item in _listservicesObjectInDelibility)
             {
                 _erroContent += item.ToString() + "\n";
             }
             XtraCustomMessageBox.Show(_erroContent, "Lỗi", true, 4);
         }
         else
             XtraCustomMessageBox.Show("Xóa dữ liệu thành công", "Thông báo", true, 1);
     }
     catch (System.Exception)
     {
         XtraCustomMessageBox.Show("Xóa dữ liệu thất bại", "Lỗi", true, 4);
     }
     finally
     {
         updateEnableButtonAndResetValueOfControl(ref btnDelete);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Phương thức cập nhật một Services xuống csdl theo id
        /// </summary>
        /// <returns>true: thêm mới thành công, false: thêm mới thất bại</returns>
        public bool UpdateServices(DTOServices Services)
        {
            try
            {
                return servicesDAO.UpdateServices(Services);
            }
            catch (SqlException)
            {

                throw;
            }
        }