Exemple #1
0
        public void deleteFile(Int32 fileID)
        {
            //Set variables
            isSucces = false;

            // Determin the ConnectionString
            string connectionString = DBSource.ConnectionStringPBox;

            // Determin the DataAdapter = CommandText + Connection
            string commandText = "SELECT * FROM FileMemo WHERE file_id=" + fileID;

            // Make a new object
            helperPData = new dBHelper(connectionString);
            {
                // Load Data
                if (helperPData.Load(commandText, "file_id") == true)
                {
                    // Determin if the row was found
                    if (helperPData.DataSet.Tables[0].Rows.Count == 1)
                    {
                        // Found, delete row
                        helperPData.DataSet.Tables[0].Rows[0].Delete();
                        try
                        {
                            // Save -> determin succes
                            if (helperPData.Save() == true)
                            {
                                isSucces = true;
                                helperPData.Dbgc();
                                Boolean delDataRs = deleteFileData(fileID);
                                if (!delDataRs)
                                {
                                    MessageBox.Show("删除文件数据失败!");
                                }
                            }
                            else
                            {
                                isSucces = false;
                                MessageBox.Show("删除文件失败!");
                            }
                        }
                        catch (Exception ex)
                        {
                            // Show the Exception --> Dubbel ContactId/Name ?
                            MessageBox.Show(ex.Message);
                        }
                    }
                }
            }
        }
Exemple #2
0
        public Boolean deleteFileData(Int32 fileID)
        {
            //Set variables
            Boolean rtnSucces = false;

            // Determin the ConnectionString
            string connectionString = DBSource.ConnectionStringPData;

            // Determin the DataAdapter = CommandText + Connection
            string commandText = "SELECT * FROM FileStore WHERE file_id=" + fileID;

            // Make a new object
            helperPData = new dBHelper(connectionString);
            {
                // Load Data
                if (helperPData.Load(commandText, "file_id") == true)
                {
                    for (int i = helperPData.DataSet.Tables[0].Rows.Count - 1; i >= 0; i--)
                    {
                        // Found, delete row
                        helperPData.DataSet.Tables[0].Rows[i].Delete();
                    }
                    try
                    {
                        // Save -> determin succes
                        if (helperPData.Save() == true)
                        {
                            rtnSucces = true;
                            helperPData.Dbgc();
                        }
                        else
                        {
                            rtnSucces = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        // Show the Exception --> Dubbel ContactId/Name ?
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            return(rtnSucces);
        }