コード例 #1
0
        public static async void PostDocumentSalary(
            [ServiceBusTrigger("q.planbutlerupdatesalary", Connection = "butlerSend")] Microsoft.Azure.ServiceBus.Message messageHeader,
            [Blob("{Label}", FileAccess.ReadWrite, Connection = "StorageSend")] CloudBlockBlob blob,
            ILogger log)
        {
            string          payload   = Encoding.Default.GetString(messageHeader.Body);
            SalaryDeduction orderBlob = new SalaryDeduction();

            orderBlob.Order = new List <Order>();
            orderBlob       = JsonConvert.DeserializeObject <SalaryDeduction>(payload);
            string   name = string.Empty;
            DateTime date = DateTime.Now;

            foreach (var item in orderBlob.Order)
            {
                date = item.Date;
                break;
            }

            var stringday   = date.Day.ToString();
            var stringMonth = date.Month.ToString();

            blob.Metadata.Add("month", stringMonth);
            blob.Metadata.Add("day", stringday);
            await blob.UploadTextAsync(payload);

            await blob.SetMetadataAsync();
        }
コード例 #2
0
        /// <summary>
        /// Deletes the orderfor salary deduction.
        /// </summary>
        /// <param name="order">The order.</param>
        /// <param name="serviceBusConnectionString">The service bus connection string.</param>
        public void DeleteOrderforSalaryDeduction(Order order, string serviceBusConnectionString)
        {
            SalaryDeduction salaryDeduction = new SalaryDeduction();
            var             dayId           = order.Date.Date.DayOfYear;

            salaryDeduction = JsonConvert.DeserializeObject <SalaryDeduction>(BotMethods.GetDocument("salarydeduction", "orders_" + dayId.ToString() + "_" + DateTime.Now.Year + ".json", this.botConfig.Value.StorageAccountUrl, this.botConfig.Value.StorageAccountKey));
            var collection = salaryDeduction.Order.FindAll(x => x.Name == order.Name);
            var temp       = collection.FindAll(x => x.CompanyStatus == order.CompanyStatus);

            salaryDeduction.Order.Remove(temp[temp.Count - 1]);

            try
            {
                BotMethods.PutDocument("salarydeduction", "orders_" + dayId.ToString() + "_" + DateTime.Now.Year.ToString() + ".json", JsonConvert.SerializeObject(salaryDeduction), "q.planbutlerupdatesalary", serviceBusConnectionString);
            }
            catch // enters if blob dont exist
            {
                List <Order> orders = new List <Order>();

                salaryDeduction.Daynumber = dayId;
                salaryDeduction.Name      = "SalaryDeduction";

                orders.Add(order);
                salaryDeduction.Order = orders;

                BotMethods.PutDocument("salarydeduction", "orders_" + dayId.ToString() + "_" + DateTime.Now.Year.ToString() + ".json", JsonConvert.SerializeObject(salaryDeduction), "q.planbutlerupdatesalary", serviceBusConnectionString);
            }
        }
コード例 #3
0
        public async Task <IActionResult> postSalaryDeductions([FromBody] PostNewSalaryDeductions postNewSalaryDeductions)
        {
            if (postNewSalaryDeductions == null)
            {
                return(Json(new
                {
                    msg = "No Data"
                }
                            ));
            }

            var orgId = getOrg();

            try
            {
                SalaryDeduction orgSalaryDeduction = new SalaryDeduction()
                {
                    Id = Guid.NewGuid(),
                    EmployeeDetailId = postNewSalaryDeductions.EmployeeDetailsId,
                    DeductionId      = postNewSalaryDeductions.DeductionId,
                    Amount           = postNewSalaryDeductions.Amount,
                    Description      = postNewSalaryDeductions.Description,
                    OrganisationId   = orgId,
                };

                _context.Add(orgSalaryDeduction);
                _context.SaveChanges();


                return(Json(new
                {
                    msg = "Success"
                }
                            ));
            }
            catch (Exception ee)
            {
            }

            return(Json(
                       new
            {
                msg = "Fail"
            }));
        }
コード例 #4
0
        private async Task <DialogTurnResult> GetMoneyStepAsync1(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var msg = string.Empty;

            int             dayNumber = DateTime.Now.DayOfYear;
            SalaryDeduction money     = JsonConvert.DeserializeObject <SalaryDeduction>(BotMethods.GetDocument("salarydeduction", "orders_" + dayNumber.ToString() + "_" + DateTime.Now.Year + ".json", this.botConfig.Value.StorageAccountUrl, this.botConfig.Value.StorageAccountKey));
            var             userId    = money.Order.FindIndex(x => x.Name == (string)stepContext.Values["name"]);

            try
            {
                string name      = stepContext.Values["name"].ToString();
                var    orderList = await BotMethods.GetDailyUserOverview(name, this.botConfig.Value.GetDailyUserOverviewFunc);

                OrderBlob orderBlob = new OrderBlob();

                msg += $"{dailyCreditDialogDepts} {Environment.NewLine}";
                string message  = string.Empty;
                string orders   = $"{dailyCreditDialogOrderMe} {Environment.NewLine}";
                double sum      = 0;
                string corders  = $"{dailyCreditDialogOrderCostumer}  {Environment.NewLine}";
                double csum     = 0;
                string iorders  = $"{dailyCreditDialogOrderTrainee}  {Environment.NewLine}";
                double isum     = 0;
                bool   check    = false;
                bool   cchecker = false;
                bool   ichecker = false;
                foreach (var item in orderList)
                {
                    foreach (var items in item.OrderList)
                    {
                        if (items.CompanyStatus.ToLower().ToString() == "extern")
                        {
                            corders += $"{items.CompanyName} \t/ {items.Restaurant} \t/ {items.Meal} \t/ {items.Price}€ {Environment.NewLine}";
                            csum    += Convert.ToDouble(items.Price);
                            cchecker = true;
                        }
                        else if (items.CompanyStatus.ToLower().ToString() == "internship")
                        {
                            iorders += $"{items.CompanyName} \t/ {items.Restaurant} \t/ {items.Meal} \t/ {items.Price}€ {Environment.NewLine}";
                            isum    += Convert.ToDouble(items.Price);
                            ichecker = true;
                        }
                        else
                        {
                            var dailyCreditDialogOrderedAt1 = string.Format(dailyCreditDialogOrderedAt, items.Meal, items.Restaurant);

                            if (check = false)
                            {
                                message = dailyCreditDialogOrderedAt1;
                            }
                            orders += $"{items.Name} \t/ {items.Restaurant} \t/ {items.Meal} \t/ {items.Price}€  {Environment.NewLine}";
                            sum    += Convert.ToDouble(items.Price);
                            check   = true;
                        }
                    }
                }

                if (check)
                {
                    var dailyCreditDialogSumMe1 = string.Format(dailyCreditDialogSumMe, sum);
                    orders += $"{dailyCreditDialogSumMe1} {Environment.NewLine}";
                }

                if (cchecker)
                {
                    var dailyCreditDialogSumCostumer1 = string.Format(dailyCreditDialogSumCostumer, csum);
                    orders  += corders;
                    corders += $"{dailyCreditDialogSumCostumer1} {Environment.NewLine}";
                }

                if (ichecker)
                {
                    var dailyCreditDialogSumTrainee1 = string.Format(dailyCreditDialogSumTrainee, csum);
                    iorders += $"{dailyCreditDialogSumTrainee1} {Environment.NewLine}";
                    orders  += iorders;
                }

                msg += $"{orders}";
            }
            catch
            {
            }

            // Get the Order from the BlobStorage, the current day ID and nameId from the user

            await stepContext.Context.SendActivityAsync(MessageFactory.Text(msg), cancellationToken);

            await stepContext.EndDialogAsync(cancellationToken : cancellationToken);

            return(await stepContext.BeginDialogAsync(nameof(OverviewDialog)));
        }
コード例 #5
0
        /// <summary>
        /// deduct salary of employee monthly
        /// </summary>
        /// <param name="date"></param>
        /// <param name="lid"></param>
        /// <param name="inid"></param>
        /// <param name="eid"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult SalaryDeduct(DateTime date, int lid, int inid, int eid, int id)
        {
            foreach (RepaymentSchedule s in db.RepaymentSchedules)
            {
                if (s.Status == 6 && s.EmployeeId == eid && s.LoanId == lid && s.InstallementId == inid && s.Id == id)
                {
                    TempData["msg"] = "<script>alert('Salary Deduction for this particular Employee loan is already done.');</script>";
                    return(RedirectToAction("EmployeeLoan", "Admin"));
                }
            }

            SalaryDeduction obj        = new SalaryDeduction();
            int             tempamount = 0;
            string          cmd0       = "SELECT * FROM RepaymentSchedule";
            SqlDataReader   reader0    = Database_Connection.get_instance().Getdata(cmd0);

            while (reader0.Read())
            {
                if (reader0.GetInt32(0) == eid && reader0.GetInt32(1) == inid)
                {
                    tempamount = reader0.GetInt32(2);

                    break;
                }
            }
            obj.Month = DateTimeFormatInfo.CurrentInfo.GetAbbreviatedMonthName(date.Month);
            //if (date.Month == 01)
            //    obj.Month = "January";
            //else if (date.Month == 02)
            //    obj.Month = "Feburary";
            //else
            var person = db.Employees.Where(y => y.Id == eid).First();
            int temp   = person.Salary;

            obj.SalaryAfterDeduction = person.Salary - tempamount;
            obj.LoanId         = lid;
            obj.InstallementId = inid;
            obj.EmployeeId     = eid;
            obj.Date           = DateTime.Now;

            SqlConnection cn = new SqlConnection(@"Data Source=HAIER-PC;Initial Catalog=DB64;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework");

            cn.Open();
            SqlCommand cmd = new SqlCommand("INSERT INTO SalaryDeduction(EmployeeId,InstallementId,LoanId,SalaryAfterDeduction,Date,Month) VALUES (@eid,@inid,@lid,@amount,@date,@month)", cn);

            cmd.Parameters.AddWithValue("@eid", obj.EmployeeId);
            cmd.Parameters.AddWithValue("@inid", obj.InstallementId);
            cmd.Parameters.AddWithValue("@lid", obj.LoanId);
            cmd.Parameters.AddWithValue("@amount", obj.SalaryAfterDeduction);
            cmd.Parameters.AddWithValue("@date", DateTime.Now.Date);
            cmd.Parameters.AddWithValue("@month", obj.Month);
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            cn.Close();

            //now updating status in repayment schedule table
            RepaymentSchedule model  = new RepaymentSchedule();
            string            cmd1   = "SELECT * FROM Lookup";
            SqlDataReader     reader = Database_Connection.get_instance().Getdata(cmd1);

            while (reader.Read())
            {
                if (reader.GetString(1) == "Paid")
                {
                    model.Status = reader.GetInt32(0);
                }
            }

            string cmd3 = string.Format("UPDATE  RepaymentSchedule SET Status = '{0}' WHERE  EmployeeId= '{1}' AND LoanId= '{2}' AND InstallementId= '{3}' AND Id= '{4}'", model.Status, eid, lid, inid, id);
            int    rows = Database_Connection.get_instance().Executequery(cmd3);

            return(RedirectToAction("RepaymentSchedule", "Admin"));
        }