protected void btnSave_OnClick(object sender, EventArgs e)
        {
            try
            {
                int           requestId  = int.Parse(currentId.Value);
                List <string> fileNames  = new List <string>();
                List <string> errorsList = new List <string>();
                string        path       = Server.MapPath("~/Attachments/");
                if (fupAttachment.HasFiles)
                {
                    foreach (HttpPostedFile file in fupAttachment.PostedFiles)
                    {
                        bool fileError     = false;
                        var  fileExtension = System.IO.Path.GetExtension(file.FileName).ToLower();
                        var  fileName      = string.Format("{0}_{1}{2}", Servston.Utilities.GetRandomString(5, true), System.IO.Path.GetFileNameWithoutExtension(file.FileName), fileExtension);
                        //Is the file too big to upload?
                        int fileSize = file.ContentLength;
                        if (fileSize > (6 * 1024 * 1024))
                        {
                            fileError = true;
                            errorsList.Add(string.Format("هذا لملف -{0} - قد تخطى الحجم المسموح به.", file.FileName));
                        }

                        List <string> acceptedFileTypes = new List <string>()
                        {
                            ".pdf",
                            ".doc",
                            ".docx",
                            ".jpg",
                            ".jpeg",
                            ".gif",
                            ".png"
                        };
                        if (!acceptedFileTypes.Contains(fileExtension))
                        {
                            fileError = true;
                            errorsList.Add(string.Format("امتداد هذا لملف -{0} - غير مسموح .", file.FileName));
                        }
                        if (!fileError)
                        {
                            file.SaveAs(path + fileName);
                            fileNames.Add(fileName);
                        }
                    }
                }


                if (errorsList.Count > 0)
                {
                    RedirectAndNotify(GetLocalizedUrl("providers/services-requests/inprogress-requests"), string.Join("\r\n", errorsList.ToArray()), "حدث خطأ أثناء الطلب", NotificationType.Error);
                    //Notify(string.Join("\r\n", errorsList.ToArray()), "حدث خطأ أثناء الطلب", NotificationType.Error);
                }
                else
                {
                    if (fileNames.Count > 0)
                    {
                        _serviceRequests.AddRequestAttchments(fileNames, requestId, true);
                    }
                    _serviceRequests.CloseProviderRequest(requestId);

                    RedirectAndNotify(GetLocalizedUrl("providers/services-requests/inprogress-requests"), "تم تفيذ الخدمة");
                    //Server.Transfer(GetLocalizedUrl("providers/services-requests/inprogress-requests")+ "?msg=تم تفيذ الخدمة&msgtype=0");
                }
            }
            catch (Exception ex)
            {
                Server.ClearError();
                RedirectAndNotify(GetLocalizedUrl("providers/services-requests/inprogress-requests"), "حدث خطأ أثناء الطلب", "", NotificationType.Error);
            }
        }
Exemple #2
0
        protected void btnProceed_OnClick(object sender, EventArgs e)
        {
            //string culture = "en-GB";
            //Page.Culture = Page.UICulture = culture;
            //Page.LCID = new System.Globalization.CultureInfo(culture).LCID;
            //System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(culture);
            //System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(culture);
            //SetLoogedUserInfo();
            try
            {
                ServiceRequests request     = new ServiceRequests();
                var             requestData = new Khadmatcom.Data.Model.ServiceRequest()
                {
                    MemberId    = CurrentUser.Id,
                    Details     = txtDetails.Value,
                    Count       = ddlCount.SelectedIndex,
                    CreatedDate = DateTime.Now,
                    CreatedBy   = CurrentUser.Id,
                    RequestDate = DateTime.Now,
                    // HijriDate = Servston.Utilities.GetHijriToday(),
                    StatusId  = (int)RequestStatus.New,
                    ServiceId = int.Parse(hfServiceId.Value),
                    CityId    = int.Parse(hfCityId.Value)
                };
                var options = _servicesServices.GetService(LanguageId, requestData.ServiceId).RequestOptions;

                foreach (RequestOption option in options)
                {
                    var requestOption = new RequestsOptionsAnswer()
                    {
                        Value = GetOptionValue(option.Id), OptionId = option.Id
                    };
                    requestData.RequestsOptionsAnswers.Add(requestOption);
                }

                request.AddRequest(requestData);

                // save uploaded attachment
                List <string> fileNames  = new List <string>();
                List <string> errorsList = new List <string>();
                SaveUploadedFile(fup1, fileNames, errorsList);
                SaveUploadedFile(fup2, fileNames, errorsList);
                SaveUploadedFile(fup3, fileNames, errorsList);
                SaveUploadedFile(fup4, fileNames, errorsList);
                if (errorsList.Count > 0)
                {
                    Notify(string.Join("\r\n", errorsList.ToArray()), "حدث خطأ أثناء رفع المرفقات", NotificationType.Error);
                }
                else
                {
                    if (fileNames.Count > 0)
                    {
                        request.AddRequestAttchments(fileNames, requestData.Id, false);
                    }
                }

                // show loadding control
                //Page.ClientScript.RegisterStartupScript(this.GetType(), "loadingScript", "$('#p10').modal('hide');showLoading(); ", true);

                //InitializeCulture();

                //send notifications
                Dictionary <string, string> keysValues = new Dictionary <string, string>
                {
                    { "name", CurrentUser.FullName },
                    { "no", requestData.Id.ToString() },
                    { "city", GetCities().First(x => x.CityId == requestData.CityId).Name },
                    { "ServiceName", GetServices().First(x => x.Id == int.Parse(hfServiceId.Value)).Name }
                };

                string replyToAddress  = WebConfigurationManager.AppSettings["ContactUsEmail"];
                string adminEmail      = WebConfigurationManager.AppSettings["AdminEmail"];
                string siteMasterEmail = WebConfigurationManager.AppSettings["SiteMasterEmail"];
                try
                {
                    Servston.MailManager.SendMail("client/new-request.html", keysValues, "طلب خدمة جديد ببوابة خدماتكم",
                                                  CurrentUser.Email, adminEmail, replyToAddress, new List <string>()
                    {
                        siteMasterEmail
                    });
                }
                catch (Exception ex)
                {
                }
                //finsh session
                RedirectAndNotify(Request.RawUrl, "تم طلب الخدمة");
            }
            catch (Exception ex)
            {
                Server.ClearError();
                //InitializeCulture();
                //if (ex.InnerException != null)
                //    Notify(ex.InnerException.Message, "حدث خطأ أثناء الطلب", NotificationType.Error);
                Notify("فضلا حاول فى وقت لاحق", "حدث خطأ أثناء الطلب", NotificationType.Error);
            }
        }
        protected void btnSave_OnClick(object sender, EventArgs e)
        {
            string paymentMethod = Request.Form["cars"];
            string payId         = "";

            CurrentRequest.ModifiedDate = DateTime.Now;
            SetShippingInfo();
            // save uploaded files
            List <string> fileNames  = new List <string>();
            List <string> errorsList = new List <string>();

            SaveUploadedFile(fup1, fileNames, errorsList);
            SaveUploadedFile(fup2, fileNames, errorsList);
            SaveUploadedFile(fup3, fileNames, errorsList);
            SaveUploadedFile(fup4, fileNames, errorsList);
            if (errorsList.Count > 0)
            {
                Notify(string.Join("\r\n", errorsList.ToArray()), "حدث خطأ أثناء الطلب", NotificationType.Error);
                return;
            }
            else
            if (fileNames.Count > 0)
            {
                _serviceRequests.AddRequestAttchments(fileNames, CurrentRequest.Id, false);
            }

            switch (paymentMethod)
            {
            case "1":    //online payment
                CurrentRequest.PaymentMethod = 1;
                _serviceRequests.UpdateServiceRequest(CurrentRequest);
                //PaymentManager paymentManager = new PaymentManager();
                //string brand = hfCardBrand.Value.Length > 1 ? hfCardBrand.Value : "";
                //if (brand == "mastercard") brand = "MASTER";
                if (CurrentRequest.CurrentPrice != null)
                {
                    // paymentManager.Checkout(CurrentRequest.CurrentPrice.Value, CurrentRequest.Id.ToString(),1,Servston.Utilities.GetCurrentClientIPAddress());
                    //var _return = paymentManager.Pay(CurrentRequest.CurrentPrice.Value, CurrentRequest.Id.ToString(), txtCardNo.Value, txtCardHolder.Value, txtExpiryDate.Value.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries)[0], "20" + txtExpiryDate.Value.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries)[1], txtCvv.Value, 1, Servston.Utilities.GetCurrentClientIPAddress(), brand.ToUpper());
                    // payId = _return["id"];
                    // CurrentRequest.PaymentReferanceCode = payId;
                    // fire the javascript function to pay online payOnline()
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", "payOnline();", true);
                }
                break;

            case "2":    //transfare payment...set to in progress if saved
                CurrentRequest.PaymentMethod        = 2;
                CurrentRequest.PaymentProviderName  = ddlBanks.Value;
                CurrentRequest.PaymentDate          = DateTime.ParseExact(txtDate.Value, "dd/MM/yyyy", new System.Globalization.CultureInfo("en-GB")); // DateTime.Parse(txtDate.Value);
                CurrentRequest.PaymentReferanceCode = txtRefNumber.Value;
                CurrentRequest.PaymentAccountNumber = txtBakAccountNum.Value;
                CurrentRequest.StatusId             = (int)RequestStatus.Paid;

                _serviceRequests.UpdateServiceRequest(CurrentRequest);

                //send sms to admin
                string sms =
                    string.Format(
                        "تحويل بنكي جديد على طلب رقم {0} الخاص بخدمة {1} بقيمة {2}",
                        CurrentRequest.Id, CurrentRequest.Service.Name, CurrentRequest.CurrentPrice);
                Servston.SMS smsManager = new Servston.SMS();
                smsManager.SendToAdmin(sms);
                RedirectAndNotify(GetLocalizedUrl("clients/services-requests/approved-requests"), "رجاءاَ قم بالإتصال بالإدارة للتأكد من وصول الحوالة.");
                break;

            default:

                break;
            }


            //if (paymentMethod == "1" && payId.Length > 3)
            //    Response.Redirect(HyperPayClient.MerchantConfiguration.Config.ReturnUrl, false);
        }