예제 #1
0
        public static void Main(string[] args)
        {
            int choose;

            do
            {
                ShowMenu();
                choose = ReadNumber();
                if (choose > 0 && choose < 5)
                {
                    Console.WriteLine("Nhap so thu nhat: ");
                    int no1 = ReadNumber();
                    Console.WriteLine("Nhap so tu hai: ");
                    int        no2 = ReadNumber();
                    MathNumber mn  = Calc.GetFunction(choose);
                    switch (choose)
                    {
                    case 1: Console.WriteLine("Tong 2 so: " + mn(no1, no2));
                        break;

                    case 2: Console.WriteLine("Hieu 2 so: " + mn(no1, no2));
                        break;

                    case 3: Console.WriteLine("Tich 2 so: " + mn(no1, no2));
                        break;

                    case 4: Console.WriteLine("Thuong 2 so: " + mn(no1, no2));
                        break;
                    }
                }
            } while (choose != 0);
        }
예제 #2
0
        public IEnumerable <IndivPricing> GetPricingByNationality(string id)
        {
            string SQL = @"select new_indvprice.new_indvpriceId,new_indvprice.new_pricename,
new_indvprice.new_nationalityName,new_indvprice.new_contractmonths,new_indvprice.new_monthlypaid,new_indvprice.new_periodamount
,new_indvprice.new_everymonth,new_indvprice.new_pricenumber,new_indvprice.new_pricetype,new_nationality,new_prepaid
 from new_indvprice
 where new_nationality='@id'";

            SQL = SQL.Replace("@id", id);

            DataTable           dt   = CRMAccessDB.SelectQ(SQL).Tables[0];
            List <IndivPricing> List = new List <IndivPricing>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                List.Add(new IndivPricing()
                {
                    Id              = dt.Rows[i]["new_indvpriceId"].ToString(),
                    Name            = dt.Rows[i]["new_pricename"].ToString(),
                    Number          = dt.Rows[i]["new_pricenumber"].ToString(),
                    NationalityName = dt.Rows[i]["new_nationalityName"].ToString(),
                    TypeId          = dt.Rows[i]["new_pricetype"].ToString(),
                    TypeName        = OptionsController.GetName("new_indvprice", "new_pricetype", 1025, dt.Rows[i]["new_pricetype"].ToString()),
                    ContractMonths  = MathNumber.RoundDeciaml(dt.Rows[i]["new_contractmonths"].ToString()),
                    PeriodAmount    = MathNumber.RoundDeciaml(dt.Rows[i]["new_periodamount"].ToString()),
                    EveryMonth      = MathNumber.RoundDeciaml(dt.Rows[i]["new_everymonth"].ToString()),
                    MonthelyPaid    = MathNumber.RoundDeciaml(dt.Rows[i]["new_monthlypaid"].ToString()),
                    PrePaid         = MathNumber.RoundDeciaml(dt.Rows[i]["new_monthlypaid"].ToString()),
                });
            }
            return(List);;
        }
예제 #3
0
        public IEnumerable <IndivPricing> GetIndivPrices(string nationalityId, string professionId)
        {
            string SQL = @"select distinct  * from new_indvprice 
where
new_nationality = '@nationalityId'
and new_profession = '@professionId' and statecode = 0 and new_forweb = 1";

            SQL = SQL.Replace("@nationalityId", nationalityId);
            SQL = SQL.Replace("@professionId", professionId);

            DataTable           dt   = CRMAccessDB.SelectQ(SQL).Tables[0];
            List <IndivPricing> List = new List <IndivPricing>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                List.Add(new IndivPricing()
                {
                    Id              = dt.Rows[i]["new_indvpriceId"].ToString(),
                    Name            = dt.Rows[i]["new_pricename"].ToString(),
                    Number          = dt.Rows[i]["new_pricenumber"].ToString(),
                    NationalityName = dt.Rows[i]["new_nationalityName"].ToString(),
                    TypeId          = dt.Rows[i]["new_pricetype"].ToString(),
                    TypeName        = OptionsController.GetName("new_indvprice", "new_pricetype", 1025, dt.Rows[i]["new_pricetype"].ToString()),
                    ContractMonths  = MathNumber.RoundDeciaml(dt.Rows[i]["new_contractmonths"].ToString()),
                    PeriodAmount    = MathNumber.RoundDeciaml(dt.Rows[i]["new_periodamount"].ToString()),
                    EveryMonth      = MathNumber.RoundDeciaml(dt.Rows[i]["new_everymonth"].ToString()),
                    MonthelyPaid    = MathNumber.RoundDeciaml(dt.Rows[i]["new_monthlypaid"].ToString()),
                    PrePaid         = MathNumber.RoundDeciaml(dt.Rows[i]["new_monthlypaid"].ToString()),
                    NationalityId   = nationalityId,
                    ProfessionId    = professionId,
                });
            }
            return(List);
        }
        public Entity CastToCrmEntity(RequestServiceContractPerHour contract)
        {
            Entity contractEntity = new Entity(CrmEntityName);

            contractEntity["new_hindivclintname"] = new EntityReference(CrmEntityNamesMapping.Contact, new Guid(contract.CustomerId.ToString()));
            contractEntity["new_nationality"]     = new EntityReference(CrmEntityNamesMapping.Nationality, new Guid(contract.NationalityId));
            contractEntity["new_houlrypricing"]   = new EntityReference(CrmEntityNamesMapping.HourlyPricing, new Guid(contract.HourlyPricingId));
            contractEntity["new_city"]            = new EntityReference(CrmEntityNamesMapping.City, new Guid(contract.CityId));
            contractEntity["new_district"]        = new EntityReference(CrmEntityNamesMapping.District, new Guid(contract.DistrictId));

            RequestHourlyPricing pricingObj = new RequestHourlyPricing();

            pricingObj.PromotionCode = contract.PromotionCode;

            var promotion = PromotionMgr.GetPromotionByCode(pricingObj, UserLanguage.Arabic);

            contractEntity["new_promotionid"] = new EntityReference(CrmEntityNamesMapping.Promotion, new Guid(promotion.Id));
            var totalVisits          = contract.ContractDuration * contract.NumOfVisits;
            var extraVisits          = (promotion.FreeVisitsFactor ?? 0) == 0 ? 0 : Math.Truncate((decimal)totalVisits / promotion.FreeVisitsFactor.Value);
            var totalPlusExtraVisits = totalVisits + extraVisits;

            contractEntity["new_contractsource"] = new OptionSetValue(contract.Who == 1 ? 1 : 2);  // why?

            contractEntity["new_housetype"]      = new OptionSetValue(contract.HouseType);
            contractEntity["new_floorno"]        = new OptionSetValue(contract.FloorNo);
            contractEntity["new_partmentnumber"] = contract.PartmentNo;

            contractEntity["new_houseno"] = contract.HouseNo;
            contractEntity["new_notes"]   = contract.AddressNotes;


            //if (contract.Who == 1)
            //    contractEntity["new_contractsource"] = new OptionSetValue(contract.Who);
            //else
            //    contractEntity["new_contractsource"] = new OptionSetValue(2);

            contractEntity["new_new_contractdate"] = DateTime.Now;
            contractEntity["new_contractconfirm"]  = DefaultValues.ServiceContractPerHour_IsConfirmed;
            contractEntity["statuscode"]           = new OptionSetValue(DefaultValues.ServiceContractPerHour_StatusCode);

            contract.StartDay = contract.StartDay.Replace('/', '-');

            contractEntity["new_contractstartdate"] = DateTime.ParseExact(contract.StartDay, "dd-MM-yyyy", CultureInfo.InvariantCulture);

            contractEntity["new_customerdays"] = contract.AvailableDays;
            contractEntity["new_selecteddays"] = contract.AvailableDays;
            contractEntity["new_latitude"]     = contract.Latitude;
            contractEntity["new_longitude"]    = contract.Longitude;
            contractEntity["new_mapurl"]       = "http://maps.google.com/maps?q=" + contract.Latitude + "," + contract.Longitude + "&z=15";
            contractEntity["new_paymentcode"]  = new Random().Next(0, 1000000).ToString("D6");

            Entity hourlyPricing     = HourlyPricingManager.GetCrmEntity(contract.HourlyPricingId);
            var    hourlyPricingCost = HourlyPricingManager.CalculateHourlyPricingCost(hourlyPricing, contract.NumOfHours, contract.NumOfVisits, contract.ContractDuration, contract.NumOfWorkers, promotion);

            contractEntity["new_shift"] = bool.Parse(hourlyPricing["new_shift"].ToString());

            contractEntity["new_hoursnumber"]     = new OptionSetValue(contract.NumOfHours);
            contractEntity["new_visitcount_def"]  = contract.NumOfVisits;
            contractEntity["new_weeklyvisits"]    = new OptionSetValue(contract.NumOfVisits);
            contractEntity["new_contractmonth"]   = new OptionSetValue(contract.ContractDuration);
            contractEntity["new_employeenumber"]  = new OptionSetValue(contract.NumOfWorkers);
            contractEntity["new_visitprice_def"]  = int.Parse(MathNumber.RoundDeciamlToInt(hourlyPricingCost.HourRate.ToString())) * contract.NumOfHours;
            contractEntity["new_visittotalprice"] = hourlyPricingCost.HourRate * contract.NumOfHours;
            contractEntity["new_monthvisits_def"] = contract.NumOfVisits * 4;

            //  contractEntity["new_totalvisits_def"] = contract.NumOfVisits * contract.ContractDuration; MIB Must be int
            contractEntity["new_totalvisits_def"] = (int)Math.Round(totalPlusExtraVisits, 0);

            contractEntity["new_hindivcount"]    = contract.NumOfHours;
            contractEntity["new_discount_def"]   = hourlyPricingCost.Discount;
            contractEntity["new_totalprice_def"] = (int)Math.Round(hourlyPricingCost.TotalPriceAfterPromotion, 0);   //decimal value string 180 = 180m as string not using parse
            contractEntity["new_vatrate"]        = hourlyPricingCost.VatRate / 100m;
            contractEntity["new_vatamount"]      = hourlyPricingCost.VatAmount;
            contractEntity["new_finalprice"]     = hourlyPricingCost.TotalPriceWithVat;

            contractEntity["new_onevisitprice"] = hourlyPricingCost.TotalPriceWithVat / (((int)Math.Round(totalPlusExtraVisits, 0)) * contract.NumOfWorkers);

            return(contractEntity);
        }
예제 #5
0
        private string CreateContract(string CustomerNo, string NationalityId, string HourlyPricingId, string CityId, bool Shift, string DistrictId, string SelectedDays, string ContractStartDate, string lat, string lang, string MonthsCount, int VisitCount, string TotalPrice, int HoursCount, string Discount, string MonthelyPrice, int who = 1)
        {
            //Random generator = new Random();
            String r = new Random().Next(0, 1000000).ToString("D6");


            ContractStartDate = ContractStartDate.Replace('/', '-');



            Entity contract = new Entity("new_hindvcontract");

            contract["new_hindivclintname"] = new EntityReference("contact", new Guid(CustomerNo.ToString()));
            contract["new_nationality"]     = new EntityReference("new_country", new Guid(NationalityId));
            contract["new_houlrypricing"]   = new EntityReference("new_hourlypricing", new Guid(HourlyPricingId));
            Entity hourlyPricing = GlobalCode.Service.Retrieve("new_hourlypricing", new Guid(HourlyPricingId), new ColumnSet(true));

            contract["new_visitprice_def"]  = int.Parse(MathNumber.RoundDeciamlToInt(hourlyPricing["new_hourprice"].ToString())) * HoursCount;
            contract["new_visittotalprice"] = Decimal.Parse(hourlyPricing["new_hourprice"].ToString()) * HoursCount;
            int months = int.Parse(MonthsCount);

            contract["new_visitcount_def"] = SelectedDays.Split(',').Count();

            contract["new_monthvisits_def"] = VisitCount;
            if (months != 0)
            {
                contract["new_monthvisits_def"] = (VisitCount * 4);
            }



            if (months != 0)
            {
                contract["new_contractmonth"] = months;
            }
            //else
            // contract["new_contractmonth"] = 13;
            contract["new_totalvisits_def"] = VisitCount;
            if (months != 0)
            {
                contract["new_totalvisits_def"] = VisitCount * 4 * months;
            }
            //hourlyPricing["new_totalvisits"];
            if (who == 1)
            {
                contract["new_contractsource"] = new OptionSetValue(who);
            }
            else
            {
                contract["new_contractsource"] = new OptionSetValue(2);
            }


            contract["new_hindivcount"] = HoursCount;

            contract["new_contractmonth"] = new OptionSetValue(months);


            contract["new_weeklyvisits"] = new OptionSetValue(VisitCount);

            contract["new_discount_def"] = decimal.Parse(Discount);
            // Math.Round((decimal.Parse(a.TotalbeforeDiscount) - (decimal.Parse(a.TotalbeforeDiscount) * decimal.Parse(Discount) / 100)), 2, MidpointRounding.AwayFromZero).ToString().Replace(".00", "");

            contract["new_totalprice_def"]   = int.Parse(Math.Round(decimal.Parse(TotalPrice), 0, MidpointRounding.AwayFromZero).ToString());
            contract["new_new_contractdate"] = DateTime.Now;
            contract["new_city"]             = new EntityReference("new_city", new Guid(CityId));
            contract["new_district"]         = new EntityReference("new_district", new Guid(DistrictId));
            contract["new_shift"]            = Shift == true ? false : true;
            contract["new_contractconfirm"]  = false;
            contract["statuscode"]           = new OptionSetValue(100000004);



            contract["new_contractstartdate"] = DateTime.ParseExact(ContractStartDate, "dd-MM-yyyy", CultureInfo.InvariantCulture);
            contract["new_customerdays"]      = SelectedDays;
            //  contract["new_selecteddays"] = SelectedDays;
            contract["new_latitude"]    = lat;
            contract["new_longitude"]   = lang;
            contract["new_paymentcode"] = r;
            contract["new_mapurl"]      = "http://maps.google.com/maps?q=" + lat + "," + lang + "&z=15";


            Guid contractId = GlobalCode.Service.Create(contract);



            if (!string.IsNullOrEmpty(contractId.ToString()))
            {
                //Send SMS To confirm

                try
                {
                    string contsql = @"
select new_HIndvContract.new_ContractNumber ,Contact.FirstName from new_HIndvContract,Contact
 where Contact.ContactId =new_HIndvContract.new_HIndivClintname and 
 new_HIndvContract.new_HIndvContractId='@id'";
                    contsql = contsql.Replace("@id", contractId.ToString());
                    System.Data.DataTable dtcontract = CRMAccessDB.SelectQ(contsql).Tables[0];


                    string Sql = @"select    MobilePhone,new_deviceid from Contact where  ContactId='@id'  ";

                    Sql = Sql.Replace("@id", CustomerNo);
                    System.Data.DataTable dt = CRMAccessDB.SelectQ(Sql).Tables[0];


                    //send Notification

                    string result = SendNotifications.SendNotify("," + CustomerNo, "عزيزى العميل /" + dtcontract.Rows[0]["FirstName"].ToString() + "   " + "شكرا لاختياركم شركة ناس سيتم التواصل معكم قريبا لتاكيد الموعد للعقد رقم " + dtcontract.Rows[0]["new_ContractNumber"].ToString());

                    string body = "عزيزى العميل /" + dtcontract.Rows[0]["FirstName"].ToString() + "   " + "شكرا لاختياركم شركة ناس سيتم التواصل معكم قريبا لتاكيد الموعد للعقد رقم " + dtcontract.Rows[0]["new_ContractNumber"].ToString();
                    AppleNotifications.SendPushNotification(dt.Rows[0]["new_deviceid"].ToString(), body, "شركة ناس للاستقدام");


                    //Send To SMS

                    /*  Entity SMS = new Entity("new_smsns");
                     * string UserName = ConfigurationManager.AppSettings["SMSUserName"];
                     * string SMSPassword = ConfigurationManager.AppSettings["SMSPassword"];
                     * string TagName = ConfigurationManager.AppSettings["TagName"];
                     * SMSRef.SMSServiceSoapClient sms = new SMSRef.SMSServiceSoapClient();
                     * string MobileNumber = dt.Rows[0][0].ToString();
                     * string Message = "https://nasmanpower.com/HourlyServiceContract/Maps.aspx?id=" + contractId + "  برجاء تاكيد الموقع باستخدام الرابط المرسل . شكرا لاستخدامكم شركة ناس   ";
                     * string res = sms.SendBulkSMS(UserName, SMSPassword, TagName, MobileNumber, Message);*/
                }
                catch (Exception)
                {
                    return(contractId.ToString());
                }
            }

            return(contractId.ToString());
        }