示例#1
0
        private void ReadWriteCSVFile()
        {
            string date = System.DateTime.Now.ToString("ddMMyyhhmmss");

            if (File.Exists(Server.MapPath(uppath)))
            {
                StreamReader sr      = new StreamReader(Server.MapPath(uppath));
                StreamWriter write   = new StreamWriter(Server.MapPath(output));
                CsvReader    csvread = new CsvReader(sr);
                CsvWriter    csw     = new CsvWriter(write);
                IEnumerable <Gift_Cards_Invoice> record = csvread.GetRecords <Gift_Cards_Invoice>();

                foreach (var rec in record) // Each record will be fetched and printed on the screen
                {
                    csw.WriteRecord <Gift_Cards_Invoice>(rec);
                    csw.NextRecord();
                    GiftCardsInvoiceDAL GCI = new GiftCardsInvoiceDAL();
                    GCI.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString();
                    GCI.InsertGiftCardsInvoice(rec);
                }
                sr.Close();
                write.Close();//close file streams

                if (File.Exists(Server.MapPath(uppath)))
                {
                    File.Delete(Server.MapPath(uppath));
                }
            }
        }
示例#2
0
        //private void GetGiftCardsInvoice(DateTime sdate, DateTime edate)
        //{
        //    GiftCardsInvoiceDAL GCIDAL = new GiftCardsInvoiceDAL();
        //    GCIDAL.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString();

        //    List<Gift_Cards_Invoice> GCIList = GCIDAL.GetGiftCardsInvoice(null, null, 0, sdate, edate);
        //    gvGCI.DataSource = GCIList;
        //    gvGCI.DataBind();
        //}
        protected void gvGCI_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DeleteGC")
            {
                GiftCardsInvoiceDAL GCIDAL = new GiftCardsInvoiceDAL();
                GCIDAL.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString();
                GCIDAL.DeleteGiftCardsInvoice(e.CommandArgument.ToString());
                //GetGiftCardsInvoice(null, null, DateTime.MinValue, DateTime.MinValue);
            }
        }
示例#3
0
        private void GetGiftCardsInvoice(string OrederNo, string empID, DateTime sdate, DateTime edate)
        {
            string ONO   = OrederNo;
            string empid = empID;
            GiftCardsInvoiceDAL GCIDAL = new GiftCardsInvoiceDAL();

            GCIDAL.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString();

            List <Gift_Cards_Invoice> GCIList = GCIDAL.GetGiftCardsInvoice(ONO, empid, sdate, edate);

            gvGCI.DataSource = GCIList;
            gvGCI.DataBind();
        }
示例#4
0
        protected void gvGCI_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GiftCardsInvoiceDAL GCIDAL = new GiftCardsInvoiceDAL();

            GCIDAL.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString();
            Gift_Cards_Invoice com = new Gift_Cards_Invoice();

            com.OrderId    = (gvGCI.Rows[e.RowIndex].FindControl("lblOrderId") as Label).Text;
            com.EmployeeID = (gvGCI.Rows[e.RowIndex].FindControl("lblEmployeeID") as Label).Text;
            com.LineNumber = (gvGCI.Rows[e.RowIndex].FindControl("tbLineNumber") as Label).Text;
            com.RewardName = (gvGCI.Rows[e.RowIndex].FindControl("lblRewardName") as Label).Text;
            com.OrderDate  = Convert.ToDateTime((gvGCI.Rows[e.RowIndex].FindControl("lblOrderDate") as Label).Text);
            com.LocalCost  = (gvGCI.Rows[e.RowIndex].FindControl("lblLocalCost") as Label).Text;
            com.Quantity   = Convert.ToInt32((gvGCI.Rows[e.RowIndex].FindControl("lblQuantity") as Label).Text);
            //com.ReasonofReturen = gvGCI.DataKeys[e.RowIndex].Values[1].ToString();
            com.ReasonofReturen = (gvGCI.Rows[e.RowIndex].FindControl("ddlReasonofReturen") as DropDownList).SelectedValue;
            com.Country         = gvGCI.DataKeys[e.RowIndex].Values["Country"].ToString();
            com.SKU             = gvGCI.DataKeys[e.RowIndex].Values["SKU"].ToString();
            GCIDAL.InsertGiftCardsInvoice(com);
            gvGCI.EditIndex = -1;
            GetGiftCardsInvoice(searcho, searche, sdate, edate);
        }
示例#5
0
        protected void ButtonSearch_Click(object sender, EventArgs e)
        {
            GiftCardsInvoiceDAL GCIDAL = new GiftCardsInvoiceDAL();

            GCIDAL.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString();
            if (tbSearchOrderNo.Text != "")
            {
                searcho = tbSearchOrderNo.Text;
                GetGiftCardsInvoice(searcho, searche, sdate, edate);
            }
            else if (tbSearchEmpID.Text != "")
            {
                searche = tbSearchEmpID.Text;
                GetGiftCardsInvoice(searcho, searche, sdate, edate);
            }
            else
            {
                //sdate = Convert.ToDateTime(tbSDate.Text);
                //edate = Convert.ToDateTime(tbEDate.Text);
                GetGiftCardsInvoice(searcho, searche, sdate, edate);
            }
        }
示例#6
0
        protected void BtnExport_Click(object sender, EventArgs e)
        {
            //DateTime sdate = Convert.ToDateTime(tbSDate.Text);
            //DateTime edate = Convert.ToDateTime(tbEDate.Text);
            ClientsInvoicesDAL  clientInvoice = new ClientsInvoicesDAL();
            GiftCardsInvoiceDAL GCIDAL        = new GiftCardsInvoiceDAL();

            GCIDAL.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString();
            List <Gift_Cards_Invoice> GCList            = GCIDAL.GetGiftCardsInvoice(null, null, sdate, edate);
            List <Gift_Cards_Invoice> TotalInvoicesList = GCIDAL.GetGCTotal(sdate, edate);

            foreach (var val in TotalInvoicesList)
            {
                TotalLocalCost = Convert.ToDouble(val.TotalLocalCost);
                TotalUSDCost   = Convert.ToDouble(val.TotalUSDCost);
            }
            var mem       = new MemoryStream();
            var writer    = new StreamWriter(mem, Encoding.UTF8, 1024, true);
            var csvWriter = new CsvWriter(writer);


            csvWriter.Configuration.Delimiter = ",";


            csvWriter.WriteField("OrderId");
            csvWriter.WriteField("EmployeeID");
            csvWriter.WriteField("LineNumber");
            csvWriter.WriteField("RewardName");
            csvWriter.WriteField("OrderDate");
            csvWriter.WriteField("Quantity");
            csvWriter.WriteField("LocalCost");
            csvWriter.WriteField("USDCost");
            csvWriter.WriteField("TotalUSDCost");
            csvWriter.WriteField("TotalLocalCost");
            csvWriter.NextRecord();

            int lenght = GCList.Count - 1;

            for (int i = 0; i <= lenght; i++)
            {
                csvWriter.WriteField(GCList[i].OrderId);
                csvWriter.WriteField(GCList[i].EmployeeID);
                csvWriter.WriteField(GCList[i].LineNumber);
                csvWriter.WriteField(GCList[i].RewardName);
                csvWriter.WriteField(GCList[i].OrderDate);
                csvWriter.WriteField(GCList[i].Quantity);
                csvWriter.WriteField(GCList[i].LocalCost);
                csvWriter.WriteField(GCList[i].USDCost);
                csvWriter.WriteField(TotalUSDCost);
                csvWriter.WriteField(TotalLocalCost);
                csvWriter.NextRecord();
            }
            writer.Flush();
            var data = Encoding.UTF8.GetString(mem.ToArray());

            Response.Clear();
            Response.AddHeader("content-disposition", "attachment; filename=GiftCardsInvoice.csv");
            Response.Charset     = "";
            Response.ContentType = "text/csv";
            Response.Write(data.ToString());
            Response.End();
        }