Copying and Pasting cs Code

In cs, like in almost any computer programming language, reading data from a file can be tricky. You add extra lines of code to tell the computer what to do. Sometimes you can copy and paste these lines from other peoples’ code.

For example, you can follow the pattern in this listing:

         private void btnStockOut_Click(object sender, EventArgs e)
         {
             switch (cbooption.Text)
             {
                 case "Daily Report":
                     sql = "SELECT `TRANSACTIONNUMBER` , concat(`FIRSTNAME`,' ', `LASTNAME`) as 'Customer', `NAME` AS 'Item', io.`QTY` , `TOTALPRICE` , `TRANSACTIONDATE` " +
                         " FROM `tblitems` i, `tblstock_in_out` io,`tblperson` p" +
                         " WHERE i.`ITEMID` = io.`ITEMID` AND io.`SUPLIERCUSTOMERID`=p.`SUPLIERCUSTOMERID` AND REMARKS ='StockOut' AND DATE(`TRANSACTIONDATE`)=CURDATE()";
                     reports(sql, "soldList");
                     break;

                 case "Weekly Report":
                     sql = "SELECT `TRANSACTIONNUMBER` , concat(`FIRSTNAME`,' ', `LASTNAME`) as 'Customer', `NAME` AS 'Item', io.`QTY` , `TOTALPRICE` , `TRANSACTIONDATE` " +
                         " FROM `tblitems` i, `tblstock_in_out` io,`tblperson` p" +
                         " WHERE i.`ITEMID` = io.`ITEMID` AND io.`SUPLIERCUSTOMERID`=p.`SUPLIERCUSTOMERID` AND REMARKS ='StockOut' AND WEEKDAY(`TRANSACTIONDATE`) >=0 AND WEEKDAY(`TRANSACTIONDATE`) <=4";
                     reports(sql, "soldList");
                     break;
                 case "Monthly Report":
                     sql = "SELECT `TRANSACTIONNUMBER` , concat(`FIRSTNAME`,' ', `LASTNAME`) as 'Customer', `NAME` AS 'Item', io.`QTY` , `TOTALPRICE` , `TRANSACTIONDATE` " +
                         " FROM `tblitems` i, `tblstock_in_out` io,`tblperson` p" +
                         " WHERE i.`ITEMID` = io.`ITEMID` AND io.`SUPLIERCUSTOMERID`=p.`SUPLIERCUSTOMERID` AND REMARKS ='StockOut' AND MONTH(`TRANSACTIONDATE`)=MONTH(CURDATE())";
                     reports(sql, "soldList");
                     break;

             }
         }