Esempio n. 1
0
        public int Update(Models.MPaidSalary model)
        {
            Common.Logger l         = new Common.Logger();
            string        ClassName = "CPaidSalary";

            try
            {
                var query = from o in obj.PaidSalaries where Convert.ToString(o.id) == model.id select o;

                foreach (var item in query)
                {
                    item.EmployeeId = Convert.ToInt32(model.EmployeeId);
                    item.SalaryId   = Convert.ToInt32(model.SalaryId);
                    item.MonthPaid  = model.MonthPaid;
                }
                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model Values id[" + model.id + "] EmployeeId[" + model.EmployeeId + "] SalaryId[" + model.SalaryId + "] MonthPaid[" + model.MonthPaid + "] Paid [ " + model.Paid + " ]");
                obj.SubmitChanges();
                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Updated Successfully");
                return(1);
            }
            catch (Exception ex)
            {
                l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString());
                return(-1);
            }
        }
Esempio n. 2
0
        public int Save(Models.MPaidSalary model)
        {
            Common.Logger l         = new Common.Logger();
            string        ClassName = "CPaidSalary";

            try
            {
                DB.PaidSalary bs = new DB.PaidSalary();
                bs.id         = Convert.ToInt32(model.id);
                bs.EmployeeId = Convert.ToInt32(model.EmployeeId);
                bs.SalaryId   = Convert.ToInt32(model.SalaryId);
                bs.MonthPaid  = model.MonthPaid;
                bs.Paid       = model.Paid;
                bs.DatePaid   = Convert.ToDateTime(model.DatePaid);
                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model Values id[" + model.id + "] EmployeeId[" + model.EmployeeId + "] SalaryId[" + model.SalaryId + "] MonthPaid[" + model.MonthPaid + "] Paid [ " + model.Paid + " ]");
                obj.PaidSalaries.InsertOnSubmit(bs);
                obj.SubmitChanges();
                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Inserted Successfully");
                return(1);
            }
            catch (Exception ex)
            {
                l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString());
                return(-1);
            }
        }
Esempio n. 3
0
        public List <Models.MPaidSalary> GetAllbyid(int id)
        {
            List <Models.MPaidSalary> model = new List <Models.MPaidSalary>();
            var query = from o in obj.PaidSalaries where Convert.ToString(o.id) == id.ToString() select o;

            foreach (var item in query)
            {
                Models.MPaidSalary m = new Models.MPaidSalary();
                m.id         = Convert.ToString(item.id);
                m.EmployeeId = Convert.ToString(item.EmployeeId);
                m.SalaryId   = Convert.ToString(item.SalaryId);
                m.MonthPaid  = item.MonthPaid;
                m.Paid       = item.Paid;
                model.Add(m);
            }

            return(model);
        }
Esempio n. 4
0
        public List <Models.MPaidSalary> GetAll()
        {
            List <Models.MPaidSalary> model = new List <Models.MPaidSalary>();
            var query = from o in obj.PaidSalaries select o;

            foreach (var item in query)
            {
                Classes.CEmployees cp           = new CEmployees();
                string             EmployeeName = string.Empty;
                EmployeeName = cp.GetEmployeeNameById(Convert.ToInt32(item.EmployeeId));
                Models.MPaidSalary m = new Models.MPaidSalary();
                m.id           = Convert.ToString(item.id);
                m.EmployeeName = EmployeeName;
                m.EmployeeId   = Convert.ToString(item.EmployeeId);
                m.SalaryId     = Convert.ToString(item.SalaryId);
                m.MonthPaid    = item.MonthPaid;
                m.Paid         = item.Paid;
                m.DatePaid     = item.DatePaid.ToString();
                model.Add(m);
            }

            return(model);
        }
Esempio n. 5
0
        private int SavePaymentOfEmployee()
        {
            int    AccountId     = Convert.ToInt32(ddlAccount.SelectedValue);
            int    CashAccountId = Convert.ToInt32(ddlCashAccount.SelectedValue);
            string EmployeeId    = ddlEmployee.SelectedValue;
            string MonthPaid     = txtMonth.Text;
            string SalaryId      = Session["WareHouse"].ToString();
            string Paid          = txtPaidAmount.Text;
            string DatePaid      = txtDateOfPayment.Text;

            Classes.CPaidSalary cp = new Classes.CPaidSalary();
            Models.MPaidSalary  mp = new Models.MPaidSalary();
            mp.EmployeeId = EmployeeId;
            mp.MonthPaid  = MonthPaid;
            mp.Paid       = Paid;
            mp.SalaryId   = SalaryId;
            mp.DatePaid   = DatePaid;

            int option = Convert.ToInt32(ddlOption.SelectedValue);

            if (option < 1)
            {
                return(-4);
            }
            if (cp.Save(mp) > 0)
            {
                switch (option)
                {
                case 1:
                {
                    Classes.CBankOfAccount      cab = new Classes.CBankOfAccount();
                    Classes.CAccountTransaction cat = new Classes.CAccountTransaction();
                    Models.MAccountTransaction  mat = new Models.MAccountTransaction();
                    float AccountTotal = cab.ReturnTotalOfAccountById(AccountId);
                    AccountTotal = AccountTotal - Convert.ToSingle(Paid);
                    if (cab.SetNewAccountTotal(AccountId, AccountTotal) > 0)
                    {
                        // float PreviousAccountTotal = cab.ReturnTotalOfAccountById(AccountId);
                        mat.AccountId          = AccountId.ToString();
                        mat.Credit             = "0";
                        mat.CurrentTransaction = "-1";
                        mat.Debit       = Paid;
                        mat.Description = "Paid Salary for the month of [" + MonthPaid + "] to " +
                                          "Employee[" + ddlEmployee.SelectedItem.Text + "] Amount [" + Paid + "]";
                        mat.eDate        = Convert.ToDateTime(DatePaid);
                        mat.FiscalYearId = Convert.ToInt32(Session["FiscalYear"]).ToString();
                        //  PreviousAccountTotal = PreviousAccountTotal - Convert.ToSingle(Paid);
                        mat.Total = AccountTotal.ToString();
                        if (cat.Save(mat) > 0)
                        {
                            Classes.CJournal cj = new Classes.CJournal();
                            Models.MJournal  mj = new Models.MJournal();
                            mj.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.SalaryExpense).ToString();
                            mj.amount = mp.Paid;
                            mj.des    = "Payment of Employee  [" + ddlEmployee.SelectedItem.Text + "] ";
                            mj.e_date = (DatePaid);
                            mj.type   = Common.Constants.Accounts.Type.Debit.ToString();
                            cj.Save(mj);

                            mj        = new Models.MJournal();
                            mj.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.Cash).ToString();
                            mj.amount = mp.Paid;
                            mj.des    = "Payment of Employee  [" + ddlEmployee.SelectedItem.Text + "] ";
                            mj.e_date = (DatePaid);
                            mj.type   = Common.Constants.Accounts.Type.Credit.ToString();
                            cj.Save(mj);

                            return(1);
                        }
                        else
                        {
                            return(-3);
                        }
                    }
                    else
                    {
                        return(-2);
                    }
                }

                case 2:
                {
                    Classes.CCashAccount     cab = new Classes.CCashAccount();
                    Classes.CCashTransaction cat = new Classes.CCashTransaction();
                    Models.MCashTransactions mat = new Models.MCashTransactions();
                    float AccountTotal           = cab.ReturnTotalOfCashAccount(CashAccountId);
                    AccountTotal = AccountTotal - Convert.ToSingle(Paid);
                    if (cab.SetNewAccountTotal(CashAccountId, AccountTotal) > 0)
                    {
                        // float PreviousAccountTotal = cab.ReturnTotalOfAccountById(AccountId);
                        mat.CashAccountId = CashAccountId;
                        mat.Credit        = "0";
                        mat.Debit         = Paid;
                        mat.Description   = "Paid Salary for the month of [" + MonthPaid + "] to " +
                                            "Employee[" + ddlEmployee.SelectedItem.Text + "] Amount [" + Paid + "]";
                        if (cat.Save(mat) > 0)
                        {
                            Classes.CJournal cj = new Classes.CJournal();
                            Models.MJournal  mj = new Models.MJournal();
                            mj.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.SalaryExpense).ToString();
                            mj.amount = mp.Paid;
                            mj.des    = "Payment of Employee  [" + ddlEmployee.SelectedItem.Text + "] ";
                            mj.e_date = (DatePaid);
                            mj.type   = Common.Constants.Accounts.Type.Debit.ToString();
                            cj.Save(mj);

                            mj        = new Models.MJournal();
                            mj.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.Cash).ToString();
                            mj.amount = mp.Paid;
                            mj.des    = "Payment of Employee  [" + ddlEmployee.SelectedItem.Text + "] ";
                            mj.e_date = (DatePaid);
                            mj.type   = Common.Constants.Accounts.Type.Credit.ToString();
                            cj.Save(mj);

                            return(1);
                        }
                        else
                        {
                            return(-3);
                        }
                    }
                    else
                    {
                        return(-2);
                    }
                }

                default:
                    return(-5);
                }
            }
            else
            {
                return(-1);
            }
        }