//#End Region
    protected void btnOrder_Click(object sender, System.EventArgs e)
    {
        clsCart = new clsAddToCart();
        if (Session["captcha"] != null)
        {
            if (Session["captcha"].ToString() != txtCode.Text)
            {
                lblMsg.Text = "Invalid Code";
                FillCapctha();
                txtCode.Text = "";
            }
            else
            {
                //place order
                if (clsCart.CheckIsCod())
                {
                    MaxCOD = (double)cls.ReturnScaler("Select_CODLimit");

                    if (clsCart.TotalPrice() > MaxCOD)
                    {
                        MsgBox("Cash On Delivery not available on your order, as it exceeds max limit of " + MaxCOD);
                        return;
                    }
                    else
                    {
                        //place order and insert into db
                        Session["PaySuccess"] = "1";
                        Session["PayMode"]    = "Cash On Delivery";
                        Response.Redirect("PaymentSuccess.aspx");
                    }
                }
                else
                {
                    MsgBox("Cash On Delivery not available on your order, as some of the products in cart not available on Cash On Delivery");
                    return;
                }
            }
        }
        else
        {
            FillCapctha();
        }
    }
 protected double getCODLimit()
 {
     MaxCOD = (double)cls.ReturnScaler("Select_CODLimit");
     return(MaxCOD);
 }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (!IsSizeSet())
        {
            MsgBox("Please Select Size");
            return;
        }
        if (!IsColorSet())
        {
            MsgBox("Please Select Color");
            return;
        }

        string concat = Guid.NewGuid().ToString();
        string strDoc = "";

        if (fupPhoto.HasFile != false)
        {
            string ext = null;
            ext = Path.GetExtension(fupPhoto.PostedFile.FileName).ToLower();
            if ((ext != ".jpg") & (ext != ".jpeg") & (ext != ".gif") & (ext != ".png") & (ext != ".bmp"))
            {
                lblMsg.Text = "Please select jpg or gif or png or bmp  files only";
                fupPhoto.Focus();
                return;
            }

            //''''''Create an image object from the uploaded file
            System.Drawing.Image FrontImage = null;
            FrontImage = System.Drawing.Image.FromStream(fupPhoto.PostedFile.InputStream);
            ///'''''''''''Determine width and height of uploaded image
            double UploadedImageWidth  = FrontImage.PhysicalDimension.Width;
            double UploadedImageHeight = FrontImage.PhysicalDimension.Height;
            double isoscalar           = 0;
            double newWidth            = 0;
            double newHeight           = 0;

            isoscalar = Math.Min((356 / UploadedImageWidth), (500 / UploadedImageHeight));
            newWidth  = isoscalar * UploadedImageWidth;
            newHeight = isoscalar * UploadedImageHeight;


            int nwidth  = 0;
            int wheight = 0;
            nwidth  = Convert.ToInt32(newWidth);
            wheight = Convert.ToInt32(newHeight);

            int x = 0;
            int y = 0;
            x = (356 - nwidth) / 2;
            y = (500 - wheight) / 2;

            Bitmap newImage = default(Bitmap);
            newImage = new Bitmap(356, 500);
            newImage.SetResolution(72, 72);
            //web resolution;
            //create a graphics object
            Graphics gr = default(Graphics);
            gr = Graphics.FromImage(newImage);
            //just in case it's a transparent GIF force the bg to white
            SolidBrush sb = default(SolidBrush);
            sb = new SolidBrush(System.Drawing.Color.Transparent);
            //sb = New SolidBrush(System.Drawing.Color.Transparent)
            gr.FillRectangle(sb, 0, 0, newImage.Width, newImage.Height);
            //Re-draw the image to the specified height and width
            gr.DrawImage(FrontImage, x, y, nwidth, wheight);
            newImage.Save(Server.MapPath("../Product/") + concat + ext);
            strDoc = "Product/" + concat + ext;
        }
        else
        {
            if (lblId.Text != "")
            {
                strDoc = ViewState["img"].ToString();
            }
            else
            {
                lblMsg.Text = "Please Select Image";
                return;
            }
        }
        //checking isarrival or not
        bool isaarival;

        if (rbtNewArriaval.SelectedValue == "1")
        {
            isaarival = true;
        }
        else
        {
            isaarival = false;
        }
        //checking special offer or not
        bool isspecial;

        if (RbtSpecialOffer.SelectedValue == "1")
        {
            isspecial = true;
        }
        else
        {
            isspecial = false;
        }

        //checking ISCOD or not
        bool iscod;

        if (rbtCOD.SelectedValue == "1")
        {
            iscod = true;
        }
        else
        {
            iscod = false;
        }


        double mrp = 0;

        if (txtMRP.Text != "")
        {
            mrp = Convert.ToDouble(txtMRP.Text);
        }

        if (string.IsNullOrEmpty(lblId.Text))
        {
            if (cls.CheckExistField("CheckExistField", "Product", "ProductName", txtProductname.Text, "and IsActive = 1 and ProductCategoryID ='" + ddlCategory.SelectedValue + "' and ProductSubCategoryID ='" + ddlSubCategory.SelectedValue + "'"))
            {
                lblMsg.Text = "This product already exists.";
                return;
            }
            else
            {
                Int32 pid;
                pid = (Int32)cls.ReturnScaler("Insert_Product", new SqlParameter("@ProductCategoryId", Convert.ToInt32(ddlCategory.SelectedValue.ToString())),
                                              new SqlParameter("@ProductSubCategoryId", Convert.ToInt32(ddlSubCategory.SelectedValue.ToString())),
                                              new SqlParameter("@SupplierId", Convert.ToInt32(ddlsupplier.SelectedValue.ToString())),
                                              new SqlParameter("@BrandId", Convert.ToInt32(ddlBrand.SelectedValue.ToString())),
                                              new SqlParameter("@ProductName", txtProductname.Text),
                                              new SqlParameter("@Productdescp", txtProductline2.Text),
                                              new SqlParameter("@ProductCode", txtProductCode.Text),
                                              new SqlParameter("@SupplierProductCode", txtSupProductcode.Text),
                                              new SqlParameter("@PackSize", txtpacksize.Text),
                                              new SqlParameter("@ProductCost", Convert.ToDouble(txtProductcost.Text)),
                                              new SqlParameter("@UnitId", Convert.ToInt32(ddlUnit.SelectedValue.ToString())),
                                              new SqlParameter("@ProductWeight", Convert.ToDouble(txtProductweight.Text)),
                                              new SqlParameter("@Image", strDoc),
                                              new SqlParameter("@KeyWords", txtkeywords.Text),
                                              new SqlParameter("@Certification", txtCertification.Text),
                                              new SqlParameter("@Description", txtDescription.Text),
                                              new SqlParameter("@Margin", txtmargin.Text),
                                              new SqlParameter("@SalePrice", Convert.ToDouble(txtsalescost.Text)),
                                              new SqlParameter("@Tax", Convert.ToDouble(txttax.Text)),
                                              new SqlParameter("@SalesPrice_Incl", Convert.ToDouble(txtSalesPriceIncl.Text)),
                                              new SqlParameter("@MRP", mrp),
                                              new SqlParameter("@Discount", Convert.ToDouble(txtDiscount.Text)),
                                              new SqlParameter("@ShippingCost", Convert.ToDouble(txtshippingcost.Text)),
                                              new SqlParameter("@FinalSellingPrice", Convert.ToDouble(txtfinalcost.Text)),
                                              new SqlParameter("@TaxFinalPrice", Convert.ToDouble(txttaxfinalprice.Text)),
                                              new SqlParameter("@Quantity", Convert.ToDouble(txtMinOrdrQty.Text)),
                                              new SqlParameter("@ShippingDays", txtShippngDays.Text),
                                              new SqlParameter("@IsNewArrival", isaarival),
                                              new SqlParameter("@IsSpecialOffer", isspecial),
                                              new SqlParameter("@IsCOD", iscod),
                                              new SqlParameter("@IsActive", 1));

                //insert into product size and product Colour
                InsertProdSize(pid);
                InsertProdColour(pid);

                clearall();
                lblMsg.Text = "Details inserted successfully.";
                BindProduct();
            }
        }
        else
        {
            cls.ExecuteDA("Update_Product", new SqlParameter("@Id", Convert.ToInt32(lblId.Text)),
                          new SqlParameter("@ProductCategoryId", Convert.ToInt32(ddlCategory.SelectedValue.ToString())),
                          new SqlParameter("@ProductSubCategoryId", Convert.ToInt32(ddlSubCategory.SelectedValue.ToString())),
                          new SqlParameter("@SupplierId", Convert.ToInt32(ddlsupplier.SelectedValue.ToString())),
                          new SqlParameter("@BrandId", Convert.ToInt32(ddlBrand.SelectedValue.ToString())),
                          new SqlParameter("@ProductName", txtProductname.Text),
                          new SqlParameter("@Productdescp", "ABC"),
                          new SqlParameter("@ProductCode", txtProductCode.Text),
                          new SqlParameter("@SupplierProductCode", txtSupProductcode.Text),
                          new SqlParameter("@PackSize", txtpacksize.Text),
                          new SqlParameter("@ProductCost", Convert.ToDouble(txtProductcost.Text)),
                          new SqlParameter("@UnitId", Convert.ToInt32(ddlUnit.SelectedValue.ToString())),
                          new SqlParameter("@ProductWeight", Convert.ToDouble(txtProductweight.Text)),
                          new SqlParameter("@Image", strDoc),
                          new SqlParameter("@KeyWords", txtkeywords.Text),
                          new SqlParameter("@Certification", txtCertification.Text),
                          new SqlParameter("@Description", txtDescription.Text),
                          new SqlParameter("@Margin", txtmargin.Text),
                          new SqlParameter("@SalePrice", Convert.ToDouble(txtsalescost.Text)),
                          new SqlParameter("@Tax", Convert.ToDouble(txttax.Text)),
                          new SqlParameter("@SalesPrice_Incl", Convert.ToDouble(txtSalesPriceIncl.Text)),
                          new SqlParameter("@MRP", mrp),
                          new SqlParameter("@Discount", Convert.ToDouble(txtDiscount.Text)),
                          new SqlParameter("@ShippingCost", Convert.ToDouble(txtshippingcost.Text)),
                          new SqlParameter("@FinalSellingPrice", Convert.ToDouble(txtfinalcost.Text)),
                          new SqlParameter("@TaxFinalPrice", Convert.ToDouble(txttaxfinalprice.Text)),
                          new SqlParameter("@Quantity", Convert.ToDouble(txtMinOrdrQty.Text)),
                          new SqlParameter("@ShippingDays", txtShippngDays.Text),
                          new SqlParameter("@IsNewArrival", isaarival),
                          new SqlParameter("@IsSpecialOffer", isspecial),
                          new SqlParameter("@IsCOD", iscod),
                          new SqlParameter("@IsActive", 1));

            //Update Product Size nad product Colour
            cls.ExecuteDA("Delete_ProductColour", new SqlParameter("@ProductId", Convert.ToInt32(lblId.Text)));
            InsertProdColour(Convert.ToInt32(lblId.Text));

            cls.ExecuteDA("Delete_ProductSize", new SqlParameter("@ProductId", Convert.ToInt32(lblId.Text)));
            InsertProdSize(Convert.ToInt32(lblId.Text));

            lblMsg.Text = "Details updated successfully.";
            clearall();
            BindProduct();
        }
    }
    protected void btnGenerate_Click(object sender, EventArgs e)
    {
        //checking product selected or not
        if (checkproducts())
        {
            //insert into db

            //update order status in invoice master
            cls.ExecuteDA("Update_InvoiceOrderStatus", new SqlParameter("@InvoiceId", invoiceid),
                          new SqlParameter("@OrderStatus", drpStatus.SelectedItem.Text));

            //calculate

            CalcualtePrices();

            //insert into invoice dispatch

            id = (long)cls.ReturnScaler("Insert_InvoiceDispatch", new SqlParameter("@InvoiceId", Convert.ToInt32(invoiceid)),
                                        new SqlParameter("@InvoiceNumber", lblInvoiceNo.Text),
                                        new SqlParameter("@InvoiceNo", invno),
                                        new SqlParameter("@CourierName", drpCourier.SelectedItem.Text),
                                        new SqlParameter("@URL", drpCourier.SelectedValue.ToString()),
                                        new SqlParameter("@TrackingNumber", txtTrackingNo.Text),
                                        new SqlParameter("@InvoiceDate", cls.FormatDate_IND_US(txtDate.Text)),
                                        new SqlParameter("@Barcode", txtTrackingNo.Text),
                                        new SqlParameter("@OtherDetails", txtOtherDetails.Text),
                                        new SqlParameter("@InvoiceAmount", ViewState["InvoiceAmount"]),
                                        new SqlParameter("@InvoiceDiscountPer", ViewState["InvoiceDiscountPer"]),
                                        new SqlParameter("@InvoiceDiscountAmount", ViewState["InvoiceDiscountAmount"]),
                                        new SqlParameter("@InvoiceOriginalAmount", ViewState["InvoiceOriginalAmount"]));

            //insert into invoice dispatch product
            foreach (RepeaterItem ri in rptPendingproducts.Items)
            {
                CheckBox chk = (CheckBox)ri.FindControl("chk");
                if (chk != null)
                {
                    if (chk.Checked == true)
                    {
                        cls.ExecuteDA("Insert_InvoiceDispatchProduct", new SqlParameter("@InvoiceId", invoiceid),
                                      new SqlParameter("@InvoiceDispatchId", id),
                                      new SqlParameter("@ProductId", chk.ToolTip.ToString()));

                        //update isdispatch in invoice product
                        cls.ExecuteDA("Update_InvoiceProductIsDispatch", new SqlParameter("@InvoiceId", Convert.ToInt32(invoiceid)),
                                      new SqlParameter("@ProductId", chk.ToolTip.ToString()),
                                      new SqlParameter("@IsDispatched", 1));
                    }
                }
            }
            // create pdf and sending mail
            string invdisid = id.ToString();
            string inid     = Request.QueryString["ID"].ToString();

            setPdfandMail(invdisid, inid);
            Response.Redirect("Orders.aspx");
        }
        else
        {
            MsgBox("Please select product to generate invoice");
        }
    }
示例#5
0
    //protected void getOnlinePaymentValues()
    //{
    //    string workingKey = "F6EDD60823178133A01936283D402E0C";//put in the 32bit alpha numeric key in the quotes provided here
    //    CCACrypto ccaCrypto = new CCACrypto();
    //    string encResponse = ccaCrypto.Decrypt(Request.Form["encResp"], workingKey);
    //    NameValueCollection Params = new NameValueCollection();
    //    string[] segments = encResponse.Split('&');
    //    foreach (string seg in segments)
    //    {
    //        string[] parts = seg.Split('=');
    //        if (parts.Length > 0)
    //        {
    //            string Key = parts[0].Trim();
    //            string Value = parts[1].Trim();
    //            Params.Add(Key, Value);
    //        }
    //    }
    //    Response.Write(Params[3].ToString());
    //    if (Params[3].ToString() == "Success")
    //    {
    //        // insert into db
    //        trackingid = Params.Keys[1].ToString();
    //        UpdateIntoDB();
    //        RemoveSession();
    //        BindTopCartItems();
    //        pnlSuccess.Visible = true;
    //    }
    //    else if (Params[3].ToString() == "Aborted")
    //    {
    //        ShowMessageThenRedirectTo("Transaction Aborted", "default");
    //    }
    //    else
    //    {
    //        ShowMessageThenRedirectTo("Transaction Failure", "default");
    //    }
    //}


    protected void InsertIntoDB()
    {
        clsCart = new clsAddToCart();
        long orderid;

A:
        orderid = (long)cls.ReturnScaler("Select_MaxOrderID");

        if (cls.CheckExistField("CheckExistField", "InvoiceMaster", "OrderId", orderid.ToString(), " and IsActive=1"))
        {
            goto A;
        }

        long      Memberid = 0;
        DataTable dtMember = new DataTable();

        dtMember = (DataTable)Session["MemberInfo"];
        foreach (DataRow dr in dtMember.Rows)
        {
            Memberid = Convert.ToInt64(dr["MemberId"]);
        }

        bool IsPaid = true;
        bool IsCOD  = false;

        if (Session["PayMode"].ToString() == "Cash On Delivery")
        {
            IsPaid = false;
            IsCOD  = true;
        }
        if (Session["PayMode"].ToString() == "Cheque / Demand Draft" || Session["PayMode"].ToString() == "Deposit in Bank A/C")
        {
            IsPaid = false;
        }

        double discount      = 0;
        double discountValue = 0;

        if (Session["Discount"] != null)
        {
            discount      = (double)Session["Discount"];
            discountValue = (double)Session["DiscountValue"];
        }

        //Insert into invoice master
        Int32 invoiceid;

        invoiceid = (Int32)cls.ReturnScaler("Insert_InvoiceMaster", new SqlParameter("MemberId", Memberid),
                                            new SqlParameter("@OrderId", orderid),
                                            new SqlParameter("@ShippingCharges", "0"),
                                            new SqlParameter("@OrderAmount", clsCart.TotalPrice()),
                                            new SqlParameter("@OrderQty", clsCart.TotalQty()),
                                            new SqlParameter("@PaypalId", trackingid),
                                            new SqlParameter("@IsPaid", IsPaid),
                                            new SqlParameter("@IsCOD", IsCOD),
                                            new SqlParameter("@PaymentMode", Session["PayMode"].ToString()),
                                            new SqlParameter("@DiscountPer", discount),
                                            new SqlParameter("@DiscountAmount", discountValue),
                                            new SqlParameter("@OriginalAmount", clsCart.TotalPriceWithoutDiscount()));


        //Insert into invoice coupon
        if (Session["CouponCode"] != null)
        {
            DataTable dtCoupon = new DataTable();
            dtCoupon = cls.ReturnDataTable("Select_CouponOnName", new SqlParameter("@CouponName", Session["CouponCode"].ToString()));

            if (dtCoupon.Rows.Count > 0)
            {
                cls.ExecuteDA("Insert_InvoiceCoupon", new SqlParameter("@InvoiceId", invoiceid),
                              new SqlParameter("@CouponName", dtCoupon.Rows[0]["CouponName"]),
                              new SqlParameter("@CriteriaAVal", dtCoupon.Rows[0]["CriteriaAVal"]),
                              new SqlParameter("@CriteriaBVal", dtCoupon.Rows[0]["CriteriaBVal"]),
                              new SqlParameter("@CriteriaCVal", dtCoupon.Rows[0]["CriteriaCVal"]));
            }
        }


        //insert into invoice product table

        DataTable dt = new DataTable();

        dt = clsCart.BindCart();
        foreach (DataRow dr in dt.Rows)
        {
            cls.ExecuteDA("Insert_InvoiceProduct", new SqlParameter("@InvoiceId", invoiceid),
                          new SqlParameter("@ProductId", Convert.ToInt32(dr["ProductId"])),
                          new SqlParameter("@CategoryName", dr["CategoryName"]),
                          new SqlParameter("@SubCategoryName", dr["SubCategoryName"]),
                          new SqlParameter("@ProductName", dr["ProductName"]),
                          new SqlParameter("@Productdescp", dr["Productdescp"]),
                          new SqlParameter("@BrandName", dr["BrandName"]),
                          new SqlParameter("@SupplierName", dr["SupplierName"]),
                          new SqlParameter("@Unit", dr["Unit"]),
                          new SqlParameter("@ColourName", dr["ColourName"]),
                          new SqlParameter("@SizeName", dr["SizeName"]),
                          new SqlParameter("@ProductCode", dr["ProductCode"]),
                          new SqlParameter("@SupplierProductCode", dr["SupplierProductCode"]),
                          new SqlParameter("@PackSize", dr["PackSize"]),
                          new SqlParameter("@ProductCost", dr["ProductCost"]),
                          new SqlParameter("@ProductWeight", dr["ProductWeight"]),
                          new SqlParameter("@Image", dr["Image"]),
                          new SqlParameter("@Certification", dr["Certification"]),
                          new SqlParameter("@Description", dr["Description"]),
                          new SqlParameter("@Margin", Convert.ToDouble(dr["Margin"])),
                          new SqlParameter("@SalePrice", Convert.ToDouble(dr["SalePrice"])),
                          new SqlParameter("@Tax", Convert.ToDouble(dr["Tax"])),
                          new SqlParameter("@SalesPrice_Incl", Convert.ToDouble(dr["SalesPrice_Incl"])),
                          new SqlParameter("@MRP", Convert.ToDouble(dr["MRP"])),
                          new SqlParameter("@Discount", Convert.ToDouble(dr["Discount"])),
                          new SqlParameter("@CalDiscount", Convert.ToDouble(dr["CalDiscount"])),
                          new SqlParameter("@ShippingCost", Convert.ToDouble(dr["ShippingCost"])),
                          new SqlParameter("@FinalSellingPrice", Convert.ToDouble(dr["FinalSellingPrice"])),
                          new SqlParameter("@TaxFinalPrice", Convert.ToDouble(dr["TaxFinalPrice"])),
                          new SqlParameter("@Quantity", Convert.ToDouble(dr["Qty"])),
                          new SqlParameter("@ShippingDays", dr["ShippingDays"]),
                          new SqlParameter("@IsCOD", Convert.ToBoolean(dr["IsCOD"])));
        }

        //inserting into billing and delivery details
        clsBSD = new BillingShippingDetails();
        DataTable dtbilship = new DataTable();

        dtbilship = clsBSD.BindBillShip();

        foreach (DataRow drow in dtbilship.Rows)
        {
            ViewState["ToMail"] = drow["SEmail"];
            cls.ExecuteDA("Insert_InvoiceBillingShipping", new SqlParameter("@InvoiceId", invoiceid),
                          new SqlParameter("@Name", drow["Name"]),
                          new SqlParameter("@Email", drow["Email"]),
                          new SqlParameter("@Company", drow["Company"]),
                          new SqlParameter("@Contact", drow["Contact"]),
                          new SqlParameter("@Address1", drow["Address1"]),
                          new SqlParameter("@Address2", drow["Address2"]),
                          new SqlParameter("@City", drow["City"]),
                          new SqlParameter("@State", drow["State"]),
                          new SqlParameter("@Country", drow["Country"]),
                          new SqlParameter("@Zipcode", drow["Zipcode"]),
                          new SqlParameter("@SName", drow["SName"]),
                          new SqlParameter("@SEmail", drow["SEmail"]),
                          new SqlParameter("@SCompany", drow["SCompany"]),
                          new SqlParameter("@SContact", drow["SContact"]),
                          new SqlParameter("@SAddress1", drow["SAddress1"]),
                          new SqlParameter("@SAddress2", drow["SAddress2"]),
                          new SqlParameter("@SCity", drow["SCity"]),
                          new SqlParameter("@SState", drow["SState"]),
                          new SqlParameter("@SCountry", drow["SCountry"]),
                          new SqlParameter("@SZipcode", drow["SZipcode"]));
        }

        //  Session["OrderId"] = orderid.ToString();
        lblOredrId.Text = orderid.ToString();
        setPdfandMail(invoiceid, orderid);
    }