Exemplo n.º 1
0
    void StartUploadingPictures()
    {
        try
        {
            string             ext = hfMasterID.Value + "_cars_";
            HttpFileCollection hfc = Request.Files; // Get the HttpFileCollection

            #region "start uploading"

            for (int i = 0; i < hfc.Count; i++)
            {
                HttpPostedFile hpf = hfc[i];
                if (hpf.ContentLength > 0)
                {
                    string fileName = hfMasterID.Value + "_" + RandomValuess.GetUniqueKey() + hpf.FileName.Substring(hpf.FileName.LastIndexOf('.'));
                    string _path    = Server.MapPath("~/Public/image/carParts/");

                    // Save full size image to the server.
                    hpf.SaveAs(_path + fileName);

                    // Save thumb to the server.
                    MinutesuaeConcrete.SaveThumb(fileName, _path);

                    // insert into db.
                    SaveImagesInDB(fileName);

                    //
                    this.divMessage.InnerHtml += "<b>Picture: </b>" + hpf.FileName + "  <b>Size:</b> " +
                                                 hpf.ContentLength + "  <b>Type:</b> " + hpf.ContentType + " Uploaded Successfully <br/>";
                    this.divMessage.Attributes.Add("class", "green-alert");
                }
            }
            #endregion
        }
        catch (Exception ex)
        {
            lblError.Text = "Error: " + ex.Message; lblError.Visible = true; lblError.ForeColor = System.Drawing.Color.DarkRed;
        }
    }
Exemplo n.º 2
0
    private void SavePayment()
    {
        CarExpense exp = new CarExpense();

        exp.ExpenseID = (hfID.Value != "" ? Convert.ToInt64(hfID.Value) : 0);
        exp.InOutType = "payment";

        //exp.Active = cbActive.Checked;
        exp.CompanyType = "cash";
        exp.InvoiceCode = RandomValuess.RandomNumber(4, 99999).ToString();
        exp.Notes       = txtNotes.Text;
        //exp.Car_ID = Convert.ToInt64(lblCompanyCode.Text);
        exp.ExpenseType_ID = Convert.ToInt32(ddlExpenseType.SelectedValue);
        exp.PaymentDate    = DateTime.Now;
        exp.ExpenseValue   = Convert.ToDecimal(txtValue.Text);
        exp.PaymentValue   = 1; // Exchange ratio. ==> 0.2722
        //exp.DueDate = Convert.ToDateTime(txtDueDate.Text);
        //exp.Company_ID = Convert.ToInt64(ddlDueforCompany.SelectedValue);
        exp.Currency_ID = 2; // Dirham.
        //exp.ExchangeCompany_ID = Convert.ToInt64(ddlExchangeCo.SelectedValue);

        exp.Store_ID = 1;
        exp.WhoAdd   = ClientSession.Current.loginId;
        exp.EditIP   = exp.AddIP = ClientSession.Current.IP;


        if (new ExpensesManager().SaveExpense(exp))
        {
            string url = ResolveClientUrl("StoreExpensesView.aspx");
            Response.RedirectPermanent(url);
        }
        else
        {
            lblError.Text = Resources.AdminResources_en.ErrorSave;
        }
    }