コード例 #1
0
        public string DeleteClass(string callType, string xmlMessage)
        {
            string result = "", id = "";
            string logID = Guid.NewGuid().ToString();

            try
            {
                FileLogger.WriteLog(logID + "|Start:" + xmlMessage, 1, "", callType);

                if (Helper.CheckAuthCode(callType, xmlMessage))
                {
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(xmlMessage);
                    XmlNode vNode = doc.SelectSingleNode(callType + "/ClassID");
                    if (vNode == null || vNode.InnerText.Trim().Length == 0)
                    {
                        throw new Exception("资料类型ID不能为空");
                    }

                    ItemClass iClass = new ItemClass();
                    id = vNode.InnerText.Trim();
                    if (iClass.Delete(id) != "-1")
                    {
                        result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                                 "<" + callType + ">" +
                                 "<Result>True</Result>" +
                                 "<ClassID>" + id + "</ClassID>" +
                                 "<Description></Description></" + callType + ">";
                    }
                    else
                    {
                        result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                                 "<" + callType + ">" +
                                 "<Result>False</Result>" +
                                 "<Description></Description></" + callType + ">";
                    }
                }
            }
            catch (Exception err)
            {
                result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                         "<" + callType + ">" +
                         "<Result>False</Result>" +
                         "<Description>" + err.Message + "</Description></" + callType + ">";
            }
            FileLogger.WriteLog(logID + "|End:" + result, 1, "", callType);
            return(result);
        }
コード例 #2
0
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     try
     {
         i.ItemId = Int32.Parse(textBoxItemId.Text);
         bool isSuccessful = i.Delete(i);
         if (isSuccessful)
         {
             MessageBox.Show("Item Deleted Successfully");
             Clear();
             DataTable dt = i.Select();
             itemsList.DataSource = dt;
         }
         else
         {
             MessageBox.Show("Error Deleting Item");
         }
     }
     catch
     {
         MessageBox.Show("Please select an item to delete");
     }
 }