http://www.imomin.webs.com

Thank You for Visit Me

Md. Mominul Islam

view:  full / summary

Dtabase Restore And Backup in C#

Posted by imomins on May 12, 2011 at 8:45 AM Comments comments (0)

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Text;

using System.Windows.Forms;

using Microsoft.SqlServer.Management.Smo;

using Microsoft.SqlServer.Management.Common;

using Microsoft.SqlServer.Management;

using System.IO;

using net.ERP.AIMS.Constants;

using net.ERP.AIMS.Utility;

using net.ERP.AIMS.DatabaseSchema.DBExistanceChecking;

using System.Linq;

using System.Data.Sql;

using System.Data.SqlClient;

 

namespace net.ERP.AIMS.Modules.Settings.GUI.Config

{

    public partial class frmSettingsConfigDatabaseBackup : Form

    {       

        public frmSettingsConfigDatabaseBackup()

        {

            InitializeComponent();

        }

        private static Server srvSql;

 

        //private string mpristrFolderNameOne = "net.ERP.AIMS(Backup).bak";

        //private string mpristrFolderNameTwo = "\net.ERP.AIMS(Backup).bak";

 

        private void cmdLocation_Click(object sender, EventArgs e)

        {            

            FolderBrowserDialog folderDlg = new FolderBrowserDialog();

            folderDlg.ShowNewFolderButton = true;          

            DialogResult result = folderDlg.ShowDialog();

            if (result == DialogResult.OK)

            {

                txtBrowse.Text = folderDlg.SelectedPath;               

                //folderBrowserDialog.SelectedPath = txtBrowse.Text + @"\net.ERP.AIMS(Backup).bak";                               

            }

        }

 

        private void cmdBackup_Click(object sender, EventArgs e)

        {

            string lstrToday = DateTime.Today.ToString("(MM-dd-yyyy)");

            string lstrFileName = null;

            if (txtBrowse.TextLength == 3)

            {

                lstrFileName = "DATABASE_BACKUP";

            }

            else

            {

                lstrFileName = @"\DATABASE_BACKUP";

            }                       

            string lstrExtension = ".bak";

            string lstrFilePath = null;

            string lstrTodayFile = lstrFileName + lstrToday + lstrExtension;

            if (srvSql != null)

            {

                // Create a new backup operation

                Backup bkpDatabase = new Backup();               

                // Set the backup type to a database backup

                bkpDatabase.Action = BackupActionType.Database;

                // Set the database that we want to perform a backup on               

                bkpDatabase.Database = clsCommonConstants.gmpubcstrDatabaseName;

                // Set the backup device to a file          

                BackupDeviceItem bkpDevice = new BackupDeviceItem(txtBrowse.Text + lstrTodayFile, DeviceType.File);

                bkpDatabase.Devices.Add(bkpDevice);               

                //Add the backup device to the backup                       

                lstrFilePath = txtBrowse.Text + lstrTodayFile;

                if (File.Exists(lstrFilePath))

                {

                    File.Delete(lstrFilePath);

                }             

                // Perform the backup

                bkpDatabase.SqlBackup(srvSql);

                MessageBox.Show("Backup Successfull");              

            }

            else

            {

                // There was no connection established; probably the Connect button was not clicked

                MessageBox.Show("A connection to a SQL server was not established.", "Not Connected to Server", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

            }

        }

 

        private void DatabaseBackup_Load(object sender, EventArgs e)

        {

            ServerConnection srvConn = new ServerConnection(clsCommonConstants.gmpubstastrServerName.ToString());

            srvSql = new Server(srvConn);          

        }

 

        private void cmdRestore_Click(object sender, EventArgs e)

        {

            string lstrToday = DateTime.Today.ToString("(MM-dd-yyyy)");

            string lstrFileName = null;

            if (txtBrowse.TextLength == 3)

            {

                lstrFileName = "DATABASE_BACKUP";

            }

            else

            {

                lstrFileName = @"\DATABASE_BACKUP";

            }

            string lstrExtension = ".bak";           

            string lstrTodayFile = lstrFileName + lstrToday + lstrExtension;        

            if (srvSql != null)

            {                           

                Restore rstDatabase = new Restore();

                BackupDeviceItem bkpDevice = new BackupDeviceItem(txtBrowse.Text + lstrTodayFile, DeviceType.File);

                // Add the backup device to the restore type

                rstDatabase.Devices.Add(bkpDevice);                

                // Set the database that we want to perform the restore on               

                rstDatabase.Database = clsCommonConstants.gmpubcstrDatabaseName;

                // Set the restore type to a database restore

                rstDatabase.Action = RestoreActionType.Database;

                // If the database already exists, replace it                                                               

                rstDatabase.ReplaceDatabase = true;             

                // Perform the restore

                rstDatabase.SqlRestore(srvSql);

                MessageBox.Show("Restore Successfull");         

            }

            else

            {

                // There was no connection established; probably the Connect button was not clicked

                MessageBox.Show("A connection to a SQL server was not established.", "Not Connected to Server", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

            }         

        }

 

        private void txtBrowse_TextChanged(object sender, EventArgs e)

        {

 

        }     

    }

}

 


Drop Database Using C#

Posted by imomins on May 12, 2011 at 7:57 AM Comments comments (0)

 private void mprivDleteDB()

        {

 

 

            string mpristrSQL = string.Format("use master; drop database NET_ERP_REMS");

            OperationGateway.mpubiExecuteSQLStmt(mpristrSQL);

 

        }

 


Valid Email Address Checking

Posted by imomins on May 12, 2011 at 7:56 AM Comments comments (0)

public static bool isEmail(string inputEmail)

{

inputEmail = NulltoString(inputEmail);

string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +

@"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +

@".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";

Regex re = new Regex(strRegex);

if (re.IsMatch(inputEmail))

return (true);

else

return (false);


Import Data from EXCEL TO SQL

Posted by imomins on May 12, 2011 at 7:46 AM Comments comments (0)

using Excel = Microsoft.Office.Interop.Excel;


string Path = @"f:\ACC_LEDGER_TROYEE.xls";

            Excel.Application app = new Excel.Application();

            Excel.Workbook workBook = app.Workbooks.Open(Path, 0, false, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);

            Excel.Worksheet workSheet = (Excel.Worksheet)workBook.ActiveSheet;

            int index = 0;

            object rowIndex = 2;

            object colIndex1 = 1;

            object colIndex2 = 2;

            object colIndex3 = 3;

try

                {

                    while (((Excel.Range)workSheet.Cells[rowIndex, colIndex1]).Value != null)

                    {

                        rowIndex = 2 + index;

                        //mpristrLedgerSerialNo = ((Excel.Range)workSheet.Cells[rowIndex, colIndex1]).Value.ToString();

                        mpristrLedgerName = ((Excel.Range)workSheet.Cells[rowIndex, colIndex2]).Value.ToString();

                        liLedgerPartyType = Convert .ToInt16 (((Excel.Range)workSheet.Cells[rowIndex, colIndex3]).Value);

                        mpristrLedgerCurrencySymbol = ((Excel.Range)workSheet.Cells[rowIndex, colIndex4]).Value.ToString();

clsOperationGateway.mpubstaiInsertIntoAccLedger(tbleAccLedger);

                        clsOperationGateway.mpubstaiUpdateAccLedgerForExcel(mpristrLedgerName, mpristrLedgerCodeTemp, mpristrLedgerCode, mpristrLedgerCurrencySymbol, mpristrLedgerGroupCode, mpridblOpeningBalance, mpridblFCOpeningBalance, mpridblClosingBalance, mpridblOnAccountValue, mpridblDebit, mpridblCredit, mpridblCreditLimit, mpridblCreditPeriod, mpristrAddress1, mpristrCountry, mpristrCity, mpristrPostal, mpristrFax, mpristrTelephone, mpristrMobile, mpristrEmailAddress, mpristrContactPer, mpriiCostCentreStatus, mpriiPayroll, mpriiEffectInventory, mpriiLedgerStatus, mpristrComments, mpristrLedgerInsertDate);

                        index++;

                    }

                    

                }

                   

                catch (Exception ex)

                {

                    app.Quit();

                    Console.WriteLine(ex.Message);

                }

                MessageBox.Show("Successfully Imported...........");

                 

        }


 

 

How To Send Email Using C#

Posted by imomins on May 12, 2011 at 7:44 AM Comments comments (0)

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Net.Mail;

using System.Text.RegularExpressions;

using System.Net;

 

 

 

namespace net.ERP.Modules.Marketing.GUI.Master

{

    public partial class frmEmail : Form

    {

        public frmEmail()

        {

            InitializeComponent();

        }

       

        private void button3_Click(object sender, EventArgs e)

        {

            try

            {

 

                MailMessage mail = new MailMessage();

                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");

                mail.From = new MailAddress("[email protected]");

                mail.To.Add("[email protected]");

                mail.Subject = "Test Mail";

                mail.Body = "This is for testing SMTP mail from GMAIL";

                SmtpServer.Port = 587;

                SmtpServer.Credentials = new System.Net.NetworkCredential("userid", "Password");

                SmtpServer.EnableSsl = true;

                SmtpServer.Send(mail);

                MessageBox.Show("mail Send");

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.ToString());

            }

 

        }

    }

}

 


How To Send Email Using C#

Posted by imomins on May 12, 2011 at 7:44 AM Comments comments (0)

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Net.Mail;

using System.Text.RegularExpressions;

using System.Net;

 

 

 

namespace net.ERP.Modules.Marketing.GUI.Master

{

    public partial class frmEmail : Form

    {

        public frmEmail()

        {

            InitializeComponent();

        }

       

        private void button3_Click(object sender, EventArgs e)

        {

            try

            {

 

                MailMessage mail = new MailMessage();

                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");

                mail.From = new MailAddress("[email protected]");

                mail.To.Add("[email protected]");

                mail.Subject = "Test Mail";

                mail.Body = "This is for testing SMTP mail from GMAIL";

                SmtpServer.Port = 587;

                SmtpServer.Credentials = new System.Net.NetworkCredential("[email protected]", "20121986Mominul");

                SmtpServer.EnableSsl = true;

                SmtpServer.Send(mail);

                MessageBox.Show("mail Send");

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.ToString());

            }

 

        }

    }

}

 


Export Excel to SQL Databse Using Csharp

Posted by imomins on May 12, 2011 at 6:32 AM Comments comments (0)

 int row = 2;

            string Path = @"f:\ACC_LEDGER_TROYEE.xls";

            Excel.Application app = new Excel.Application();

            Excel.Workbook workBook = app.Workbooks.Open(Path, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);

            Excel.Worksheet workSheet = (Excel.Worksheet)workBook.ActiveSheet;

 object colIndex1 = 1;

            object colIndex2 = 2;

            object colIndex3 = 3;

            object colIndex4 = 4;

clsDatabaseConnectorForTroyee databaseConnectorForTroyee = new clsDatabaseConnectorForTroyee();

            databaseConnectorForTroyee.mpubvConnectDatabaseForTroyee();

            clsDatabaseConnectorForTroyee.gmpubstasqlconnSQLConnectionForTroyee.Open();

            SqlCommand thisCommand = clsDatabaseConnectorForTroyee.gmpubstasqlconnSQLConnectionForTroyee.CreateCommand();

            string lstrSQL = "SELECT * FROM ACC_LEDGER";

            thisCommand.CommandText = lstrSQL;

            SqlDataReader thisReader = thisCommand.ExecuteReader();

            while (thisReader.Read())

            {

                workSheet.Cells[row, colIndex1].Value = Convert.ToString(thisReader["LEDGER_SERIAL"]);

                workSheet.Cells[row, colIndex2].Value = Convert.ToString(thisReader["LEDGER_NAME"]);

                workSheet.Cells[row, colIndex3].Value = Convert.ToString(thisReader["LEDGER_PARTY_TYPE"]);

 

                row++;

            }

            thisReader.Close();

            clsDatabaseConnectorForTroyee.gmpubstasqlconnSQLConnectionForTroyee.Close();

            MessageBox.Show("Excel file created , you can find the file F:\\ACC_LEDGER_TROYEE.xls");

        }


 

 

Export Excel to SQL Databse Using Csharp

Posted by imomins on May 12, 2011 at 6:32 AM Comments comments (0)

 int row = 2;

            string Path = @"f:\ACC_LEDGER_TROYEE.xls";

            Excel.Application app = new Excel.Application();

            Excel.Workbook workBook = app.Workbooks.Open(Path, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);

            Excel.Worksheet workSheet = (Excel.Worksheet)workBook.ActiveSheet;

 object colIndex1 = 1;

            object colIndex2 = 2;

            object colIndex3 = 3;

            object colIndex4 = 4;

clsDatabaseConnectorForTroyee databaseConnectorForTroyee = new clsDatabaseConnectorForTroyee();

            databaseConnectorForTroyee.mpubvConnectDatabaseForTroyee();

            clsDatabaseConnectorForTroyee.gmpubstasqlconnSQLConnectionForTroyee.Open();

            SqlCommand thisCommand = clsDatabaseConnectorForTroyee.gmpubstasqlconnSQLConnectionForTroyee.CreateCommand();

            string lstrSQL = "SELECT * FROM ACC_LEDGER";

            thisCommand.CommandText = lstrSQL;

            SqlDataReader thisReader = thisCommand.ExecuteReader();

            while (thisReader.Read())

            {

                workSheet.Cells[row, colIndex1].Value = Convert.ToString(thisReader["LEDGER_SERIAL"]);

                workSheet.Cells[row, colIndex2].Value = Convert.ToString(thisReader["LEDGER_NAME"]);

                workSheet.Cells[row, colIndex3].Value = Convert.ToString(thisReader["LEDGER_PARTY_TYPE"]);

 

                row++;

            }

            thisReader.Close();

            clsDatabaseConnectorForTroyee.gmpubstasqlconnSQLConnectionForTroyee.Close();

            MessageBox.Show("Excel file created , you can find the file F:\\ACC_LEDGER_TROYEE.xls");

        }


 

 

How to Restrict Web Browsing

Posted by imomins on May 7, 2011 at 1:06 AM Comments comments (0)

Go To:

C:\WINDOWS\system32\drivers\etc

and open 'hosts' file with notepad and write   127.0.0.1       www.facebook.com  at bottom

finally...

save it

Vocabulary and Phrases for Making Presentations in English

Posted by imomins on April 27, 2011 at 6:57 AM Comments comments (0)

Vocabulary and Phrases for Making Presentations in EnglishOverviews

After you give your opening statement, you should give a brief overview of your presentation. This includes what your presentation is about, how long you will take and how you are going to handle questions.

For example, a presentation to sales staff could start like this:

"Welcome / "Hello everyone."

Opening statement

"As you all know, this company is losing its market share. But we are being asked to increase

sales by 20 – 25%. How can we possibly increase sales in a shrinking market?"

Overview

"Today I am going to talk to you about how we can do this. My presentation will be in three parts. Firstly I am going to look at the market and the background. Then I am going to talk to you about our new products and how they fit in. Finally, I'm going to examine some selling strategies that will help us increase our sales by 20%. The presentation will probably take around 20 minutes. There will be time for questions at the end of my talk."

Useful language for overviews

"My presentation is in three parts."

"My presentation is divided into three main sections."

"Firstly, secondly, thirdly, finally…"

"I'm going to…

take a look at…

talk about…

examine…

tell you something about the background…

give you some facts and figures…

fill you in on the history of…

concentrate on…

limit myself to the question of…

"Please feel free to interrupt me if you have questions."

"There will be time for questions at the end of the presentation."

"I'd be grateful if you could ask your questions after the presentation."

The main body of the presentation

During your presentation, it’s a good idea to remind your audience occasionally of the benefit of what you are saying.

"As I said at the beginning…"

"This, of course, will help you (to achieve the 20% increase)."

"As you remember, we are concerned with…"

"This ties in with my original statement…"

"This relates directly to the question I put to you before…"

Keeping your audience with you

Remember that what you are saying is new to your audience. You are clear about the structure of your talk, but let your audience know when you are moving on to a new point. You can do this by saying something like "right", or "OK". You can also use some of the following expressions:

"I'd now like to move on to…"

"I'd like to turn to…"

"That's all I have to say about…"

"Now I'd like to look at…"

"This leads me to my next point…"

If you are using index cards, putting the link on the cards will help you remember to keep the audience with you. In addition, by glancing at your index cards you will be pausing – this will also help your audience to realise that you are moving on to something new.

Language for using visuals

It's important to introduce your visual to the audience. You can use the following phrases:

"This graph shows you…"

"Take a look at this…"

"If you look at this, you will see…"

"I'd like you to look at this…"

"This chart illustrates the figures…"

"This graph gives you a break down of…"

Give your audience enough time to absorb the information on the visual. Pause to allow them to look at the information and then explain why the visual is important:

"As you can see…"

"This clearly shows …"

"From this, we can understand how / why…"

"This area of the chart is interesting…"

Summarising

At the end of your presentation, you should summarise your talk and remind the audience of what you have told them:

"That brings me to the end of my presentation. I've talked about…"

"Well, that's about it for now. We've covered…"

"So, that was our marketing strategy. In brief, we…"

"To summarise, I…"

Relate the end of your presentation to your opening statement:

"So I hope that you're a little clearer on how we can achieve sales growth of 20%."

"To return to the original question, we can achieve…"

"So just to round the talk off, I want to go back to the beginning when I asked you…"

"I hope that my presentation today will help you with what I said at the beginning…"

Handling questions

Thank the audience for their attention and invite questions.

"Thank you for listening – and now if there are any questions, I would be pleased to answer them."

"That brings me to the end of my presentation. Thank you for your attention. I'd be glad to answer any questions you might have."

It’s useful to re-word the question, as you can check that you have understood the question and you can give yourself some time to think of an answer. By asking the question again you also make sure that other people in the audience understand the question.

"Thank you. So you would like further clarification on our strategy?"

"That's an interesting question. How are we going to get voluntary redundancy?"

"Thank you for asking. What is our plan for next year?"

After you have answered your question, check that the person who asked you is happy with the answer.

"Does this answer your question?"

"Do you follow what I am saying?"

"I hope this explains the situation for you."

"I hope this was what you wanted to hear!"

If you don't know the answer to a question, say you don't know. It's better to admit to not knowing something than to guess and maybe get it wrong. You can say something like:

"That's an interesting question. I don't actually know off the top of my head, but I'll try to get back to you later with an answer."

"I'm afraid I'm unable to answer that at the moment. Perhaps I can get back to you later."

"Good question. I really don't know! What do you think?"

"That's a very good question. However, we don't have any figures on that, so I can't give you an accurate answer."

"Unfortunately, I'm not the best person to answer that."

What can you say if things go wrong?

You think you've lost your audience? Rephrase what you have said:

"Let me just say that in another way."

"Perhaps I can rephrase that."

"Put another way, this means…"

"What I mean to say is…"

Can't remember the word?

If it's a difficult word for you – one that you often forget, or one that you have difficulty pronouncing – you should write it on your index card. Pause briefly, look down at your index card and say the word.

Using your voice

Don't speak in a flat monotone – this will bore your audience. By varying your speed and tone, you will be able to keep your audience's attention. Practise emphasising key words and pause in the right places – usually in between ideas in a sentence. For example "The first strategy involves getting to know our market (pause) and finding out what they want. (pause) Customer surveys (pause) as well as staff training (pause) will help us do this."

Don't forget – if you speak too fast you will lose your audience!

 



Rss_feed