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 <OmanFloat> record  = csvread.GetRecords <OmanFloat>();

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

                if (File.Exists(Server.MapPath(uppath)))
                {
                    File.Delete(Server.MapPath(uppath));
                }
            }
        }
Exemple #2
0
        protected void BtnAmount_Click(object sender, EventArgs e)
        {
            string confirmValue = Request.Form["confirm_value"];

            if (confirmValue == "Yes")
            {
                //this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked YES!')", true);
            }
            else
            {
                //this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked NO!')", true);
            }

            OmanFloatDAL OFDAL = new OmanFloatDAL();

            OFDAL.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString();
            double   amount      = Convert.ToDouble(tbamount.Text);
            string   s           = tbDate.Text;
            DateTime PaymentDate = Convert.ToDateTime(tbDate.Text);

            OFDAL.OmanAddAmount(amount, PaymentDate);
            GetOAmount();
            GetTAmount();
            tbamount.Text = string.Empty;
            tbDate.Text   = string.Empty;
        }
        protected void BtnExport_Click(object sender, EventArgs e)
        {
            OmanFloatDAL OFDAL = new OmanFloatDAL();

            OFDAL.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString();
            List <OmanFloat> OFList = OFDAL.GetOmanFloat(null);

            var mem       = new MemoryStream();
            var writer    = new StreamWriter(mem, Encoding.UTF8, 1024, true);
            var csvWriter = new CsvWriter(writer);


            csvWriter.Configuration.Delimiter = ",";


            csvWriter.WriteField("OrderNo");
            csvWriter.WriteField("OrderDate");
            csvWriter.WriteField("MemberName");
            csvWriter.WriteField("PaymentstoOman");
            csvWriter.WriteField("Totalcost");
            csvWriter.WriteField("Deliveryfees");
            csvWriter.WriteField("TotaCostwithDelivery");
            csvWriter.WriteField("TotalRemainingAmount");
            csvWriter.WriteField("Status");
            csvWriter.WriteField("DeliveryDate");
            csvWriter.WriteField("CardTypeandAmount");
            csvWriter.WriteField("Quantity");
            csvWriter.WriteField("Dateofpayment");
            csvWriter.NextRecord();

            int lenght = OFList.Count - 1;

            for (int i = 0; i <= lenght; i++)
            {
                csvWriter.WriteField(OFList[i].OrderNo);
                csvWriter.WriteField(OFList[i].OrderDate);
                csvWriter.WriteField(OFList[i].MemberName);
                csvWriter.WriteField(OFList[i].PaymentstoOman);
                csvWriter.WriteField(OFList[i].Totalcost);
                csvWriter.WriteField(OFList[i].Deliveryfees);
                csvWriter.WriteField(OFList[i].TotalCostwithDelivery);
                csvWriter.WriteField(OFList[i].TotalRemainingAmount);
                csvWriter.WriteField(OFList[i].Status);
                csvWriter.WriteField(OFList[i].DeliveryDate);
                csvWriter.WriteField(OFList[i].CardTypeandAmount);
                csvWriter.WriteField(OFList[i].Quantity);
                csvWriter.WriteField(OFList[i].Dateofpayment);
                csvWriter.NextRecord();
            }
            writer.Flush();
            var data = Encoding.UTF8.GetString(mem.ToArray());

            Response.Clear();
            Response.AddHeader("content-disposition", "attachment; filename=OmanFloat.csv");
            Response.Charset     = "";
            Response.ContentType = "text/csv";
            Response.Write(data.ToString());
            Response.End();
        }
Exemple #4
0
        protected void GetTAmount()
        {
            OmanFloatDAL OFDAL = new OmanFloatDAL();

            OFDAL.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString();
            Double TAmount = Convert.ToDouble(OFDAL.GetAmount());

            lblTAmount.Text = TAmount.ToString();
        }
 protected void gvOF_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "DeleteOF")
     {
         OmanFloatDAL OFDAL = new OmanFloatDAL();
         OFDAL.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString();
         OFDAL.DeleteOmanFloat(e.CommandArgument.ToString());
         GetOmanFloat();
     }
 }
        private void GetOmanFloat(string orderno)
        {
            OmanFloatDAL OFDAL = new OmanFloatDAL();

            OFDAL.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString();
            List <OmanFloat> OFList = OFDAL.GetOmanFloat(orderno);

            gvOF.DataSource = OFList;
            gvOF.DataBind();
        }
        private void GetOmanFloat()
        {
            OmanFloatDAL OFDAL = new OmanFloatDAL();

            OFDAL.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString();
            List <OmanFloat> OFList = OFDAL.GetOmanFloat(null);

            gvOF.DataSource = OFList;
            gvOF.DataBind();
            //lblTotalAmount.Text=OFList
        }
Exemple #8
0
        protected void gvOF_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            OmanFloatDAL OFDAL = new OmanFloatDAL();
            OmanAmount   com   = new OmanAmount();

            OFDAL.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString();
            com.ID             = Convert.ToInt32((gvOF.DataKeys[e.RowIndex].Values["ID"]));
            com.PaymentstoOman = Convert.ToDouble((gvOF.Rows[e.RowIndex].FindControl("tbP2O") as TextBox).Text);
            DateTime?DOP = (((gvOF.Rows[e.RowIndex].FindControl("lblDateofpayment") as Label).Text) == "")? (DateTime?)null : Convert.ToDateTime(((gvOF.Rows[e.RowIndex].FindControl("lblDateofpayment") as Label).Text));

            com.Dateofpayment = DOP;
            OFDAL.InsertOmanAmount(com);
            gvOF.EditIndex = -1;
            GetOAmount();
            GetTAmount();
        }
        protected void gvOF_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            OmanFloatDAL OFDAL = new OmanFloatDAL();
            OmanFloat    com   = new OmanFloat();

            OFDAL.ConnectionString    = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString();
            com.OrderNo               = (gvOF.Rows[e.RowIndex].FindControl("lblOrderNo") as Label).Text;
            com.OrderDate             = Convert.ToDateTime((gvOF.Rows[e.RowIndex].FindControl("lblOrderDate") as Label).Text);
            com.MemberName            = (gvOF.Rows[e.RowIndex].FindControl("lblMemberName") as Label).Text;
            com.Totalcost             = Convert.ToDouble((gvOF.Rows[e.RowIndex].FindControl("tbTotalcost") as TextBox).Text);
            com.Deliveryfees          = Convert.ToDouble((gvOF.Rows[e.RowIndex].FindControl("tbDeliveryfees") as TextBox).Text);
            com.TotalCostwithDelivery = Convert.ToDouble((gvOF.Rows[e.RowIndex].FindControl("tbTCWD") as TextBox).Text);
            com.Status = (gvOF.Rows[e.RowIndex].FindControl("tbStatus") as TextBox).Text;
            DateTime?DD = (((gvOF.Rows[e.RowIndex].FindControl("tbDD") as TextBox).Text) == "")? (DateTime?)null: Convert.ToDateTime(((gvOF.Rows[e.RowIndex].FindControl("tbDD") as TextBox).Text));

            com.DeliveryDate      = DD;
            com.CardTypeandAmount = (gvOF.Rows[e.RowIndex].FindControl("tbCardTypeandAmount") as TextBox).Text;
            com.Quantity          = Convert.ToInt32((gvOF.Rows[e.RowIndex].FindControl("tbQuantity") as TextBox).Text);

            OFDAL.InsertOmanFloat(com);
            gvOF.EditIndex = -1;
            GetOmanFloat();
        }