Пример #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (selectedRecordId != 0)
            {
                try
                {
                    Cursor = Cursors.WaitCursor;
                    EmployeeBAL _objBAL = new EmployeeBAL();
                    _objBAL.DeleteEmployee(selectedRecordId);
                    MessageBox.Show("Record has been deleted successfully!");
                    Cursor = Cursors.Default;
                    MakeEmpty();
                }
                catch (System.Data.SqlClient.SqlException sqlEx)
                {
                    if (sqlEx.Number == 547)
                    {
                        MessageBox.Show("You cannot delete this record. Its refference exists in other documents.");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

                MakeEmpty();
            }
        }
Пример #2
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "delete",
                                                                        Route = null)] HttpRequestMessage req, TraceWriter log)
        {
            string name = string.Empty;

            try
            {
                log.Info("SEG Delete Employee HTTP Function triggered...");

                // parse query parameter
                name = req.GetQueryNameValuePairs()
                       .FirstOrDefault(q => string.Compare(q.Key, "name", true) == 0)
                       .Value;

                // Get request body
                //dynamic data = await req.Content.ReadAsAsync<object>();

                // Set name to query string or body data
                //name = name ?? data?.name;

                int employeedeletedcount = 0;

                EmployeeBAL employeebal = new EmployeeBAL();
                employeedeletedcount = employeebal.DeleteEmployee(int.Parse(name));
            }
            catch (System.Exception ex)
            {
                return(req.CreateResponse(HttpStatusCode.InternalServerError,
                                          "Inside catch - " + ex.StackTrace));
                //log.Info(ex.Message + ex.StackTrace);
            }

            return(name == null
                    ? req.CreateResponse(HttpStatusCode.BadRequest, "Please pass a name on the query string or in the request body")
                    : req.CreateResponse(HttpStatusCode.OK, "Employee " + name + " deleted!"));
        }
Пример #3
0
        public IActionResult DeleteEmployee(int id)
        {
            string dltemp = employeeBAL.DeleteEmployee(id);

            return(Ok(dltemp));
        }