コード例 #1
0
        public bool checkEnoughCash()
        {
            DoctorClass         docs = new DoctorClass();
            IQueryable <doctor> ld   = docs.getAllDoctors();
            long bal = getBalance();

            foreach (var doc in ld)
            {
                bal = bal - doc.salary;
            }
            if (bal >= 0)
            {
                return(true);
            }
            return(false);
        }
コード例 #2
0
        /*     public List<item> viewBill(int BillId)
         *   {
         *       return true;
         *   }
         *  public List<bill> viewBillsInCase(int CaseId)
         *   {
         *       return true;
         *   }
         *
         */
        public bool giveSalaries()
        {
            DoctorClass docs = new DoctorClass();

            //GetAllDoctors
            IQueryable <doctor> ld = docs.getAllDoctors();
            long sal, starting_balance, final_balance;

            //Check if all doctors can be given salaries
            bool res = checkEnoughCash();

            if (res == false)
            {
                return(false);
            }
            //Give Salaries
            foreach (var doc in ld)
            {
                //Generate Cheque
                cheque chq = new cheque();
                chq.doctorid = doc.doctorid;
                chq.date     = DateTime.Now;
                chq.amount   = doc.salary;
                dc.cheques.InsertOnSubmit(chq);
                dc.SubmitChanges();

                //Log it and modify Balance
                sal = doc.salary;
                starting_balance = getBalance();
                final_balance    = starting_balance - sal;

                cost c = new cost();
                c.date             = DateTime.Now;
                c.starting_balance = starting_balance;
                c.billid           = 0;
                c.chequeid         = getLastChequeId(chq); //Cheque id of the last cheque inserted
                c.final_balance    = final_balance;
                setBalance(final_balance);
                dc.costs.InsertOnSubmit(c);
                dc.SubmitChanges();
            }
            return(true);
        }