private void cbMandal_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbMandal.SelectedIndex > 0)
            {
                clbVillage.DataSource = null;
                clbVillage.DataBindings.Clear();
                clbVillage.Items.Clear();

                objInv = new InvoiceDB();
                try
                {
                    DataTable dt = objInv.VillageMasterFilter_Get(cbStates.SelectedValue.ToString(), cbDistrict.SelectedValue.ToString(), cbMandal.SelectedValue.ToString()).Tables[0];
                    if (dt.Rows.Count > 1)
                    {
                        clbVillage.DataSource    = dt;
                        clbVillage.DisplayMember = "PANCHAYAT";
                        clbVillage.ValueMember   = "PIN";
                    }
                    dt = null;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    objInv = null;
                }
            }
        }
    private void FillEmptyAddForm()
    {
        lblHeading.Text = "Add Adjustment Note";
        Page.Title      = "Add Adjustment Note";

        idRow.Visible = false;

        Invoice invoice = InvoiceDB.GetByID(GetFormID());

        if (invoice == null)
        {
            HideTableAndSetErrorMessage("Invalid invoice ID");
            return;
        }

        lblInvoiceId.Text         = invoice.InvoiceID.ToString();
        lblAmountOwing.Text       = invoice.TotalDue.ToString();
        txtTotal.Text             = invoice.TotalDue.ToString();
        addedByRow.Visible        = false;
        creditnoteDateRow.Visible = false;
        lblReason.Visible         = false;

        btnSubmit.Text    = "Add Adjustment Note";
        btnCancel.Visible = true;
    }
Esempio n. 3
0
 private void cmbBranch_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cmbBranch.SelectedIndex > 0)
     {
         chkDocMonth.Items.Clear();
         chkVillage.Items.Clear();
         chkProducts.Items.Clear();
         objInvoiceDB = new InvoiceDB();
         ds           = objInvoiceDB.GetInvocieInfoforService(cmbBranch.SelectedValue.ToString());
         foreach (DataRow dr in ds.Tables[0].Rows)
         {
             if (!chkDocMonth.Items.Contains(dr["TNA_DOC_MONTH"].ToString()))
             {
                 chkDocMonth.Items.Add(dr["TNA_DOC_MONTH"].ToString());
             }
         }
         foreach (DataRow drV in ds.Tables[1].Rows)
         {
             if (!chkVillage.Items.Contains(drV["CM_VILLAGE"].ToString()))
             {
                 chkVillage.Items.Add(drV["CM_VILLAGE"].ToString());
             }
         }
         foreach (DataRow drP in ds.Tables[2].Rows)
         {
             if (!chkProducts.Items.Contains(drP["pm_product_name"].ToString()))
             {
                 chkProducts.Items.Add(drP["pm_product_name"].ToString());
             }
         }
         objSQLdb = null;
     }
 }
Esempio n. 4
0
        private void FillDocumentMonths()
        {
            objInv = new InvoiceDB();
            objDB  = new SQLDB();
            DataSet ds      = new DataSet();
            DataSet dschild = new DataSet();
            string  strSQL  = "SELECT DISTINCT FY_FIN_YEAR FROM FIN_YEAR";

            ds = objDB.ExecuteDataSet(strSQL);
            ttvDocMonth.Nodes.Add("DocMonths", "DocMonths");
            if (ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    ttvDocMonth.Nodes[0].Nodes.Add(ds.Tables[0].Rows[i]["FY_FIN_YEAR"].ToString(),
                                                   ds.Tables[0].Rows[i]["FY_FIN_YEAR"].ToString());
                    strSQL  = "SELECT DISTINCT DOCUMENT_MONTH,start_date FROM DOCUMENT_MONTH WHERE FIN_YEAR = '" + ds.Tables[0].Rows[i]["FY_FIN_YEAR"].ToString() + "' ORDER BY START_DATE ASC";
                    dschild = objDB.ExecuteDataSet(strSQL);
                    if (dschild.Tables[0].Rows.Count > 0)
                    {
                        for (int j = 0; j < dschild.Tables[0].Rows.Count; j++)
                        {
                            ttvDocMonth.Nodes[0].Nodes[i].Nodes.Add(dschild.Tables[0].Rows[j]["DOCUMENT_MONTH"].ToString(),
                                                                    dschild.Tables[0].Rows[j]["DOCUMENT_MONTH"].ToString());
                        }
                    }
                }
            }

            if (ds.Tables[0].Rows.Count > 0)
            {
                this.ttvDocMonth.SelectedNode = ttvDocMonth.Nodes[0];
                this.ttvDocMonth.SelectedNode.Expand();
            }
        }
        private void FillProductData(string sCategoryCode)
        {
            objInv = new InvoiceDB();

            try
            {
                if (strFLoad == "NO" && strModify == "NO")
                {
                    DataTable dt = objInv.GetProductMasterSearch(CommonData.CompanyCode, sCategoryCode).Tables[0];
                    DataRow   dr = dt.NewRow();
                    dr[0] = "Select";
                    dr[1] = "Select";
                    dt.Rows.InsertAt(dr, 0);
                    dr = null;
                    if (dt.Rows.Count > 1)
                    {
                        cbProduct.DataSource    = dt;
                        cbProduct.DisplayMember = "pm_product_name";
                        cbProduct.ValueMember   = "pm_product_id";
                    }
                    dt = null;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                objInv = null;
            }
        }
Esempio n. 6
0
        private void FillData(string sCompCode, string sBranchCode, string sFinYear, string sDocType, string sVoucherId)
        {
            objInvDB = new InvoiceDB();
            Hashtable ht = new Hashtable();

            try
            {
                ht = objInvDB.GetRecieptVoucherData(sCompCode, sBranchCode, sFinYear, sDocType, sVoucherId);
                DataTable dtH  = (DataTable)ht["Head"];
                DataTable dtD1 = (DataTable)ht["Detail1"];
                DataTable dtD2 = (DataTable)ht["Detail2"];
                FillCachPaymentHead(dtH, dtD1, dtD2);
                dtH  = null;
                dtD1 = null;
                dtD2 = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                objInvDB = null;
                ht       = null;
            }
        }
Esempio n. 7
0
        private void FillDatatoGrid( )
        {
            objData = new InvoiceDB();
            DataTable dt = null;

            if (cbEcode.SelectedIndex > -1 && txtDocMonth.Text.Length > 0)
            {
                dt = objData.GetSalesReceiptDataOfEmp(CommonData.CompanyCode, CommonData.BranchCode, CommonData.DocMonth, ((System.Data.DataRowView)(cbEcode.SelectedItem)).Row.ItemArray[0].ToString());
            }


            gvReceiptList.Rows.Clear();
            txtRevenue.Text     = "";
            txtTotReciepts.Text = "0.00";
            if (dt != null)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    gvReceiptList.Rows.Add();
                    gvReceiptList.Rows[i].Cells["SlNo"].Value        = i + 1;
                    gvReceiptList.Rows[i].Cells["Ecode"].Value       = dt.Rows[i]["EmpEcode"].ToString();
                    gvReceiptList.Rows[i].Cells["Names"].Value       = dt.Rows[i]["EmpName"].ToString();
                    gvReceiptList.Rows[i].Cells["Type"].Value        = dt.Rows[i]["Type"].ToString();
                    gvReceiptList.Rows[i].Cells["ReceiptNo"].Value   = dt.Rows[i]["ReceiptNo"].ToString();
                    gvReceiptList.Rows[i].Cells["Date"].Value        = Convert.ToDateTime(dt.Rows[i]["ReceiptDate"].ToString()).ToShortDateString();
                    gvReceiptList.Rows[i].Cells["Amount"].Value      = dt.Rows[i]["Amount"].ToString();
                    gvReceiptList.Rows[i].Cells["Remarks"].Value     = dt.Rows[i]["Remarks"].ToString();
                    gvReceiptList.Rows[i].Cells["id"].Value          = dt.Rows[i]["SSR_ID"].ToString();
                    gvReceiptList.Rows[i].Cells["RefNo"].Value       = dt.Rows[i]["RefNo"].ToString();
                    gvReceiptList.Rows[i].Cells["CreatedDate"].Value = dt.Rows[i]["CreatedDate"].ToString();
                    txtTotReciepts.Text = dt.Rows[i]["TotRecieved"].ToString();
                    txtRevenue.Text     = dt.Rows[i]["TotalRev"].ToString();
                }
            }
        }
Esempio n. 8
0
    public static EPCInfo GetEPCInfo(int patient_id)
    {
        int MedicareMaxNbrServicesPerYear        = Convert.ToInt32(SystemVariableDB.GetByDescr("MedicareMaxNbrServicesPerYear").Value);
        int NbrMedicareServicesUsedSoFarThisYear = (int)InvoiceDB.GetMedicareCountByPatientAndYear(patient_id, DateTime.Now.Year);

        return(new EPCInfo(MedicareMaxNbrServicesPerYear, NbrMedicareServicesUsedSoFarThisYear));
    }
Esempio n. 9
0
    private void FillEmptyAddForm()
    {
        lblHeading.Text = "Add Refund";
        Page.Title      = "Add Refund";

        idRow.Visible = false;

        Invoice invoice = InvoiceDB.GetByID(GetFormID());

        if (invoice == null)
        {
            HideTableAndSetErrorMessage("Invalid invoice ID");
            return;
        }

        lblInvoiceId.Text       = invoice.InvoiceID.ToString();
        lblAmountReceipted.Text = invoice.ReceiptsTotal.ToString();
        txtTotal.Text           = invoice.ReceiptsTotal.ToString();
        refundDateRow.Visible   = false;
        lblReason.Visible       = false;
        addedByRow.Visible      = false;

        btnSubmit.Text = "Add Refund";

        if (!invoice.IsPaID)
        {
            btnSubmit.OnClientClick = "javascript:if (!confirm('Refunding an unpaid invoice will automaitcally credit note it to set it as paid. Are you sure you want continue with the refund?')) return false;";
        }
        btnCancel.Visible = true;
    }
        private void FillBranches()
        {
            objInv = new InvoiceDB();
            DataSet ds = new DataSet();

            try
            {
                ds = objInv.UserBranchCursor_Get("", "", "PARENT");

                if (ds.Tables[0].Rows.Count > 0)
                {
                    tvBranches.Nodes.Add("COMPANY AND BRANCHES", "COMPANY AND BRANCHES");
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        tvBranches.Nodes[0].Nodes.Add(ds.Tables[0].Rows[i]["COMPANY_CODE"].ToString(), ds.Tables[0].Rows[i]["COMPANY_NAME"].ToString());

                        DataSet dschild = new DataSet();
                        dschild = objInv.UserBranchCursor_Get(ds.Tables[0].Rows[i]["COMPANY_CODE"].ToString(), "BR", "CHILD");

                        if (dschild.Tables[0].Rows.Count > 0)
                        {
                            for (int j = 0; j < dschild.Tables[0].Rows.Count; j++)
                            {
                                tvBranches.Nodes[0].Nodes[i].Nodes.Add(dschild.Tables[0].Rows[j]["BRANCH_CODE"].ToString(), dschild.Tables[0].Rows[j]["BRANCH_NAME"].ToString());
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            tvBranches.Nodes[0].Expand();
        }
Esempio n. 11
0
    public static bool IsValidInvoiceHash(string inString)
    {
        if (inString == null)
        {
            return(false);
        }

        inString = inString.Replace(" ", "+");

        string result = SimpleAES.Decrypt(SimpleAES.KeyType.Invoices, inString);

        if (result == null || !System.Text.RegularExpressions.Regex.IsMatch(result, @"^Mediclinic_\d{4}__\d+$"))
        {
            return(false);
        }

        string[] resultSplit = result.Split(new string[] { "__" }, StringSplitOptions.None);
        string   DB          = resultSplit[0];
        string   invNbr      = resultSplit[1];

        if (!Utilities.IsValidDB(DB.Substring(DB.Length - 4)))
        {
            return(false);
        }

        if (InvoiceDB.GetByID(Convert.ToInt32(invNbr), DB) == null)
        {
            return(false);
        }

        return(true);
    }
Esempio n. 12
0
        private int SaveOrderBookingDeatailData()
        {
            objSQLDB = new SQLDB();
            string sqlText   = "";
            string sqlDelete = "";
            int    iRes      = 0;

            try
            {
                sqlDelete = "DELETE from DL_ORDER_BOOKING_DETL WHERE DLOD_TRN_NO=" + Convert.ToInt32(strTrnNo);
                iRes      = objSQLDB.ExecuteSaveData(sqlDelete);
                for (int i = 0; i < gvProductDetails.Rows.Count; i++)
                {
                    if (gvProductDetails.Rows[i].Cells["Rate"].Value.ToString() != "" && gvProductDetails.Rows[i].Cells["Qty"].Value.ToString() != "")
                    {
                        sqlText += "INSERT INTO DL_ORDER_BOOKING_DETL(DLOD_TRN_NO,DLOD_SL_NO,DLOD_PRODUCT_ID,DLOD_PRICE,DLOD_QTY,DLOD_AMT) VALUES(" + Convert.ToInt32(strTrnNo)
                                   + "," + gvProductDetails.Rows[i].Cells["SLNO"].Value + ", '" + gvProductDetails.Rows[i].Cells["ProductID"].Value.ToString().Trim()
                                   + "', " + gvProductDetails.Rows[i].Cells["Rate"].Value + ", " + gvProductDetails.Rows[i].Cells["Qty"].Value + ", " + gvProductDetails.Rows[i].Cells["Amount"].Value + ")";
                    }
                }
                iRes = objSQLDB.ExecuteSaveData(sqlText);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                objData = null;
            }
            return(iRes);
        }
Esempio n. 13
0
    public static void Reverse(int receipt_id, int reversed_by)
    {
        Receipt receipt = ReceiptDB.GetByID(receipt_id);

        if (receipt == null)
        {
            throw new ArgumentException("Invalid receipt id :" + receipt_id);
        }
        if (receipt.IsReversed)
        {
            throw new ArgumentException("Receipt already reversed");
        }
        if (receipt.IsReconciled)
        {
            throw new ArgumentException("Can not reverse a receipt that has been reconciled");
        }


        // remove any overpayment records for this receipt
        OverpaymentDB.DeleteByReceiptID(receipt_id);

        // set total=0, set not overpaid, set who and when it was reversed, and original amount
        string sql = "UPDATE Receipt SET total = 0, is_overpaid = 0 ,reversed_by = " + reversed_by + ",reversed_date = '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',pre_reversed_amount = " + receipt.Total + " WHERE receipt_id = " + receipt_id.ToString();

        DBBase.ExecuteNonResult(sql);

        // set invoice as not paid
        InvoiceDB.UpdateIsPaid(null, receipt.Invoice.InvoiceID, false);

        // update the GL for the year this was done
    }
Esempio n. 14
0
        public void TestAddInvoice()
        {
            InvoiceController ic = new InvoiceController();

            //load first customer by calling DBcontext
            InvoiceDB db = new InvoiceDB();
            Customer  c  = db.Customers.First();

            ((IObjectContextAdapter)db).ObjectContext.Detach(c); //http://stackoverflow.com/questions/4168073/entity-framework-code-first-no-detach-method-on-dbcontext
            Assert.NotNull(c);

            Invoice i = new Invoice();

            i.CustomerID        = c.CustomerID;
            i.Customer          = c;
            i.AdvancePaymentTax = 10;
            i.Notes             = "Invoice notes";
            i.TimeStamp         = DateTime.Now;
            i.DueDate           = DateTime.Now.AddDays(90);
            i.Paid = false;
            i.Name = "Test invoice";

            System.Web.Mvc.ActionResult resultAdd = ic.Create(i);

            Assert.IsInstanceOf(typeof(System.Web.Mvc.ViewResult), resultAdd);
        }
        private void EcodeSearch()
        {
            objData = new InvoiceDB();
            DataSet dsEmp = null;

            try
            {
                Cursor.Current     = Cursors.WaitCursor;
                cbEcode.DataSource = null;
                cbEcode.Items.Clear();
                dsEmp = objData.InvLevelEcodeSearch_Get(cbCompany.SelectedValue.ToString(), cbBranches.SelectedValue.ToString().Split('@')[0], CommonData.DocMonth, txtEcodeSearch.Text);
                DataTable dtEmp = dsEmp.Tables[0];
                if (dtEmp.Rows.Count > 0)
                {
                    cbEcode.DataSource    = dtEmp;
                    cbEcode.DisplayMember = "ENAME";
                    cbEcode.ValueMember   = "ECODE";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (cbEcode.SelectedIndex > -1)
                {
                    cbEcode.SelectedIndex = 0;
                    strECode = ((System.Data.DataRowView)(cbEcode.SelectedItem)).Row.ItemArray[0].ToString();
                }
                objData        = null;
                Cursor.Current = Cursors.Default;
            }
        }
        public void TestAddInvoiceDetails()
        {
            InvoiceDB db = new InvoiceDB();
            Invoice   i  = db.Invoices.First();

            ((IObjectContextAdapter)db).ObjectContext.Detach(i); //http://stackoverflow.com/questions/4168073/entity-framework-code-first-no-detach-method-on-dbcontext
            Assert.NotNull(i);

            InvoiceDetailsController idc = new InvoiceDetailsController();

            idc.ControllerContext = new ControllerContext()
            {
                HttpContext = new MockHttpContext()
            };

            InvoiceDetails id = new InvoiceDetails();

            id.TimeStamp = DateTime.Now;
            id.Invoice   = i;
            id.Qty       = 1;
            id.Price     = 100;
            id.VAT       = 18;
            id.Article   = "Invoice details test";

            //get
            System.Web.Mvc.ActionResult resultAddView = idc.Create(i.InvoiceID);
            Assert.IsInstanceOf(typeof(System.Web.Mvc.ViewResult), resultAddView);

            //post
            System.Web.Mvc.ActionResult resultAdd = idc.Create(id);
            Assert.IsInstanceOf(typeof(System.Web.Mvc.PartialViewResult), resultAdd);

            Assert.AreEqual(((System.Web.Mvc.PartialViewResult)resultAdd).ViewName, "Index");
        }
Esempio n. 17
0
        public void TestAddInvoiceDetails()
        {
            InvoiceDB db = new InvoiceDB();
            Invoice i = db.Invoices.First();
            ((IObjectContextAdapter)db).ObjectContext.Detach(i); //http://stackoverflow.com/questions/4168073/entity-framework-code-first-no-detach-method-on-dbcontext
            Assert.NotNull(i);

            InvoiceDetailsController idc = new InvoiceDetailsController();
            idc.ControllerContext = new ControllerContext() { HttpContext=new MockHttpContext() };

            InvoiceDetails id = new InvoiceDetails();
            id.TimeStamp = DateTime.Now;
            id.Invoice = i;
            id.Qty = 1;
            id.Price = 100;
            id.VAT = 18;
            id.Article = "Invoice details test";

            //get
            System.Web.Mvc.ActionResult resultAddView = idc.Create(i.InvoiceID);
            Assert.IsInstanceOf(typeof(System.Web.Mvc.ViewResult), resultAddView);

            //post
            System.Web.Mvc.ActionResult resultAdd = idc.Create(id);
            Assert.IsInstanceOf(typeof(System.Web.Mvc.PartialViewResult), resultAdd);

            Assert.AreEqual(((System.Web.Mvc.PartialViewResult)resultAdd).ViewName, "Index");
        }
Esempio n. 18
0
    protected void lnkPrint_Command(object sender, CommandEventArgs e)
    {
        int     invoiceID = Convert.ToInt32(e.CommandArgument);
        Invoice invoice   = InvoiceDB.GetByID(invoiceID);

        Letter.GenerateInvoicesToPrint(new int[] { invoiceID }, Response, invoice.Site.SiteType.ID == 1, invoice.Booking != null);
    }
 private void cbBranch_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cbBranch.SelectedIndex > 0)
     {
         sType    = "S";
         objInvDB = new InvoiceDB();
         try
         {
             DataTable dtStates = objInvDB.GetVillagesDdlForCustList(cbCompany.SelectedValue.ToString(), cbBranch.SelectedValue.ToString(), "", "", "", "", "", "", "", 0, 0, sType).Tables[0];
             UtilityLibrary.PopulateControl(cbState, dtStates.DefaultView, 1, 0, "--PLEASE SELECT--", 0);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
         finally
         {
             objInvDB = null;
         }
     }
     else
     {
         sType = "";
         cbState.DataSource = null;
     }
 }
        private void FillEmployeeData()
        {
            objData = new InvoiceDB();

            DataSet dsEmp = null;

            try
            {
                dsEmp = objData.GetGCListForStkContra(CommonData.CompanyCode, CommonData.BranchCode, txtDocMonth.Text);
                DataTable dtEmp = dsEmp.Tables[0];
                if (dtEmp.Rows.Count > 0)
                {
                    cbEcode.DataSource    = dtEmp;
                    cbEcode.DisplayMember = "ENAME";
                    cbEcode.ValueMember   = "ECODE";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (cbEcode.SelectedIndex > -1)
                {
                    cbEcode.SelectedIndex = 0;
                    strECode = ((System.Data.DataRowView)(cbEcode.SelectedItem)).Row.ItemArray[0].ToString();
                }
                objData        = null;
                Cursor.Current = Cursors.Default;
            }
        }
    private void FillEmptyAddForm()
    {
        lblHeading.Text = "Add Receipt";
        Page.Title      = "Add Receipt";

        idRow.Visible           = false;
        isReconciledRow.Visible = false;

        Invoice invoice = InvoiceDB.GetByID(GetFormID());

        if (invoice == null)
        {
            HideTableAndSetErrorMessage("Invalid invoice ID");
            return;
        }

        lblInvoiceId.Text = invoice.InvoiceID.ToString();

        if (invoice.TotalDue > 0)
        {
            txtTotal.Text = invoice.TotalDue.ToString();
        }

        amountReconciledRow.Visible   = false;
        failedToClearRow.Visible      = false;
        isOverPaidRow.Visible         = false;
        addedByRow.Visible            = false;
        receiptDateRow.Visible        = false;
        reconciliationDateRow.Visible = false;


        btnSubmit.Text    = "Add Receipt";
        btnCancel.Visible = true;
    }
 public void TestSetup()
 {
     InvoiceDB db = new InvoiceDB();
     if (db.Invoices.Count() == 0) {
         EntitiesContextInitializer e = new EntitiesContextInitializer();
         e.InitializeDatabase(db);
     }
 }
Esempio n. 23
0
 public static int NumForeignKeyDependencies(int entity_id)
 {
     return(SiteDB.GetCountByEntityID(entity_id) +
            PersonDB.GetCountByEntityID(entity_id) +
            OrganisationDB.GetCountByEntityID(entity_id) +
            BookingDB.GetCountByEntityID(entity_id) +
            InvoiceDB.GetCountByEntityID(entity_id));
 }
Esempio n. 24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Utilities.SetNoCache(Response);
        }

        try
        {
            if (Session == null || Session["DB"] == null)
            {
                throw new SessionTimedOutException();
            }

            string patient_id = Request.QueryString["patient_id"];
            if (patient_id == null || !Regex.IsMatch(patient_id, @"^\d+$"))
            {
                throw new CustomMessageException();
            }
            Patient patient = PatientDB.GetByID(Convert.ToInt32(patient_id));
            if (patient == null)
            {
                throw new CustomMessageException();
            }

            string offering_id = Request.QueryString["offering_id"];
            if (offering_id == null || !Regex.IsMatch(offering_id, @"^\d+$"))
            {
                throw new CustomMessageException();
            }
            Offering offering = OfferingDB.GetByID(Convert.ToInt32(offering_id));
            if (offering == null)
            {
                throw new CustomMessageException();
            }

            string booking_datetime = Request.QueryString["booking_datetime"];
            if (booking_datetime == null || !Regex.IsMatch(booking_datetime, @"^\d{4}_\d{2}_\d{2}_\d{4}$"))
            {
                throw new CustomMessageException();
            }
            DateTime dateTime = ConvertStringToDateTime(booking_datetime);

            int nbrMedicareThisServiceSoFarThisPeriod = (int)InvoiceDB.GetMedicareCountByPatientAndDateRange(patient.PatientID, dateTime.Date.AddMonths(-1 * offering.MaxNbrClaimableMonths), dateTime.Date, offering.OfferingID);

            // return "[done]:[limit]"
            Response.Write(nbrMedicareThisServiceSoFarThisPeriod + ":" + offering.MaxNbrClaimable + ":" + offering.MaxNbrClaimableMonths);
        }
        catch (SessionTimedOutException)
        {
            Utilities.UnsetSessionVariables();
            Response.Write("SessionTimedOutException");
        }
        catch (Exception ex)
        {
            Response.Write("Exception: " + (Utilities.IsDev() ? ex.ToString() : "please contact system administrator."));
        }
    }
Esempio n. 25
0
        private void cbStates_SelectedIndexChanged(object sender, EventArgs e)
        {
            //if (cbStates.SelectedValue.ToString() == "NP")
            //{
            //    lblDistrict.Text = "Zone";
            //    lblMandal.Text = "District";
            //}
            //else
            //{
            //    lblDistrict.Text = "District";
            //    lblMandal.Text = "Mandal";
            //}

            if (cbStates.SelectedIndex > 0)
            {
                cbDistrict.DataSource = null;
                cbDistrict.DataBindings.Clear();
                cbDistrict.Items.Clear();

                cbMandal.DataSource = null;
                cbMandal.DataBindings.Clear();
                cbMandal.Items.Clear();

                lstMappedBranches.DataSource = null;
                lstMappedBranches.DataBindings.Clear();
                lstMappedBranches.Items.Clear();

                objInv = new InvoiceDB();
                try
                {
                    DataTable dt = objInv.VillageMasterFilter_Get(cbStates.SelectedValue.ToString(), string.Empty, string.Empty).Tables[0];
                    DataRow   dr = dt.NewRow();
                    dr[0] = "Select";
                    dt.Rows.InsertAt(dr, 0);

                    if (dt.Rows.Count > 1)
                    {
                        cbDistrict.DataSource    = dt;
                        cbDistrict.DisplayMember = "DISTRICT";
                        cbDistrict.ValueMember   = "DISTRICT";
                    }
                    dt = null;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    objInv = null;
                }
            }

            if (chkDistr.Checked == true || chkMand.Checked == true)
            {
                FillDataToList();
            }
        }
Esempio n. 26
0
        public override bool ValidateUser(string username, string password)
        {
            InvoiceDB db   = new InvoiceDB();
            var       user = (from u in db.Users
                              where u.Login == username && u.Password == password
                              select u).FirstOrDefault();

            return(user != null);
        }
Esempio n. 27
0
        private void FillBranches()
        {
            objInv = new InvoiceDB();
            DataSet ds = new DataSet();

            ds = objInv.UserBranchCursor_Get("", "", "PARENT");

            if (ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    tvBranches.Nodes.Add(ds.Tables[0].Rows[i]["COMPANY_CODE"].ToString(), ds.Tables[0].Rows[i]["COMPANY_NAME"].ToString());

                    DataSet dschild = new DataSet();
                    dschild = objInv.UserBranchCursor_Get(ds.Tables[0].Rows[i]["COMPANY_CODE"].ToString(), "BR", "CHILD");

                    if (dschild.Tables[0].Rows.Count > 0)
                    {
                        for (int j = 0; j < dschild.Tables[0].Rows.Count; j++)
                        {
                            tvBranches.Nodes[i].Nodes.Add(dschild.Tables[0].Rows[j]["BRANCH_CODE"].ToString(), dschild.Tables[0].Rows[j]["BRANCH_NAME"].ToString());
                        }
                    }

                    dschild = objInv.UserBranchCursor_Get(ds.Tables[0].Rows[i]["COMPANY_CODE"].ToString(), "SP", "CHILD");

                    if (dschild.Tables[0].Rows.Count > 0)
                    {
                        for (int j = 0; j < dschild.Tables[0].Rows.Count; j++)
                        {
                            tvBranches.Nodes[i].Nodes.Add(dschild.Tables[0].Rows[j]["BRANCH_CODE"].ToString(), dschild.Tables[0].Rows[j]["BRANCH_NAME"].ToString());
                        }
                    }

                    dschild = objInv.UserBranchCursor_Get(ds.Tables[0].Rows[i]["COMPANY_CODE"].ToString(), "PU", "CHILD");

                    if (dschild.Tables[0].Rows.Count > 0)
                    {
                        for (int j = 0; j < dschild.Tables[0].Rows.Count; j++)
                        {
                            tvBranches.Nodes[i].Nodes.Add(dschild.Tables[0].Rows[j]["BRANCH_CODE"].ToString(), dschild.Tables[0].Rows[j]["BRANCH_NAME"].ToString());
                        }
                    }

                    dschild = objInv.UserBranchCursor_Get(ds.Tables[0].Rows[i]["COMPANY_CODE"].ToString(), "TR", "CHILD");

                    if (dschild.Tables[0].Rows.Count > 0)
                    {
                        for (int j = 0; j < dschild.Tables[0].Rows.Count; j++)
                        {
                            tvBranches.Nodes[i].Nodes.Add(dschild.Tables[0].Rows[j]["BRANCH_CODE"].ToString(), dschild.Tables[0].Rows[j]["BRANCH_NAME"].ToString());
                        }
                    }
                }
            }
        }
        public void TestSetup()
        {
            InvoiceDB db = new InvoiceDB();

            if (db.Invoices.Count() == 0)
            {
                EntitiesContextInitializer e = new EntitiesContextInitializer();
                e.InitializeDatabase(db);
            }
        }
Esempio n. 29
0
        static void Main(string[] args)
        {
            AddressDB  address  = new AddressDB();
            CustomerDB customer = new CustomerDB();
            InvoiceDB  invoice  = new InvoiceDB();

            PrintInfo(address);
            PrintInfo(customer);
            PrintInfo(invoice);
        }
Esempio n. 30
0
    protected void Repeater17_ItemCreated(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            DataRowView dr = (DataRowView)e.Item.DataItem;
            if (dr == null || dr.Row == null)
            {
                return;
            }
            DataRow row     = dr.Row;
            Invoice invoice = InvoiceDB.LoadAll(row);


            // get controls
            Repeater           lstRefunds       = (Repeater)e.Item.FindControl("lstRefunds");
            HtmlGenericControl div_refunds_list = (HtmlGenericControl)e.Item.FindControl("div_refunds_list");
            HtmlGenericControl span_refunds_trailing_space_row = (HtmlGenericControl)e.Item.FindControl("span_refunds_trailing_space_row");
            Label      lnkAddRefund        = (Label)e.Item.FindControl("lnkAddRefund");
            LinkButton showHideRefundsList = (LinkButton)e.Item.FindControl("showHideRefundsList");


            // get refunds
            DataTable tblRefunds = RefundDB.GetDataTableByInvoice(invoice.InvoiceID);
            lstRefunds.Visible = tblRefunds.Rows.Count > 0;
            span_refunds_trailing_space_row.Visible = tblRefunds.Rows.Count > 0;
            if (tblRefunds.Rows.Count > 0)
            {
                tblRefunds.Columns.Add("refund_url", typeof(string));
                for (int i = 0; i < tblRefunds.Rows.Count; i++)
                {
                    Refund refund = RefundDB.LoadAll(tblRefunds.Rows[i]);
                    tblRefunds.Rows[i]["refund_url"] = refund.GetViewPopupLinkV2();
                }

                lstRefunds.DataSource = tblRefunds;
                lstRefunds.DataBind();
            }

            lnkAddRefund.Visible = tblRefunds.Rows.Count == 0;
            //if (!invoice.IsPaID) // can add items
            if (tblRefunds.Rows.Count == 0) // can add items
            {
                lnkAddRefund.Text = Refund.GetAddPopupLinkV2(invoice.InvoiceID, "window.location.href = window.location.href;");
            }
            else
            {
                lnkAddRefund.Text = tblRefunds.Rows.Count > 0 ? string.Empty : "No Refunds";
            }
            //span_add_refunds_row.Style["text-align"] = (tblRefunds.Rows.Count > 0) ? "center" : null;  // if have table, center add link, else left align
            lnkAddRefund.Visible = lnkAddRefund.Text.Length > 0 && invoice.ReceiptsTotal > 0;
            showHideRefundsList.OnClientClick   = "javascript:show_hide_byname('div_refunds_list_" + invoice.InvoiceID + "'); return false;";
            showHideRefundsList.Visible         = tblRefunds.Rows.Count > 0;
            div_refunds_list.Attributes["name"] = "div_refunds_list_" + invoice.InvoiceID;
        }
    }
Esempio n. 31
0
        private void FillInvOrBultInData(int nInvNo, string sOrderNo)
        {
            Hashtable ht;
            DataTable InvH;
            DataTable InvD;
            DataSet   ds = new DataSet();

            try
            {
                objData = new InvoiceDB();
                ht      = objData.GetInvoiceData(CommonData.StateCode, CommonData.BranchCode, nInvNo, sOrderNo);

                InvH = (DataTable)ht["InvHead"];
                InvD = (DataTable)ht["InvDetail"];
                if (InvH.Rows.Count == 0)
                {
                    ht   = objData.InvoiceBulitin_Get(CommonData.StateCode, CommonData.BranchCode, nInvNo, sOrderNo);
                    InvH = (DataTable)ht["InvHead"];
                    InvD = (DataTable)ht["InvDetail"];
                    if (InvH.Rows.Count == 0)
                    {
                        IsBiltinInvoice = false;
                        IsSaleInvoice   = false;
                    }
                    else
                    {
                        IsBiltinInvoice = true;
                        IsSaleInvoice   = false;
                    }
                }
                else
                {
                    IsBiltinInvoice = false;
                    IsSaleInvoice   = true;
                }

                FillInvoiceData(InvH, InvD);
            }
            catch (Exception ex)
            {
                objData = null;
                ht      = null;
                InvH    = null;
                InvD    = null;
                MessageBox.Show(ex.Message, "Invoice", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            finally
            {
                objData = null;
                ht      = null;
                InvH    = null;
                InvD    = null;
                ds      = null;
            }
        }
Esempio n. 32
0
    private void FillEditViewForm(bool isEditMode)
    {
        lblHeading.Text = isEditMode ? "Edit Refund" : "View Refund";
        Page.Title      = isEditMode ? "Edit Refund" : "View Refund";


        Refund refund = RefundDB.GetByID(GetFormID());

        if (refund == null)
        {
            HideTableAndSetErrorMessage("Invalid Refund ID");
            return;
        }


        lblId.Text         = refund.RefundID.ToString();
        lblInvoiceId.Text  = refund.Invoice.InvoiceID.ToString();
        lblRefundDate.Text = refund.RefundDateAdded.ToString("d MMM, yyyy");
        lblAddedBy.Text    = refund.Staff.Person.FullnameWithoutMiddlename;
        lblTotal.Font.Bold = !isEditMode;


        if (isEditMode)
        {
            txtTotal.Text = refund.Total.ToString();
            ddlRefundReason.SelectedValue = refund.RefundReason.ID.ToString();
            lblAmountReceipted.Text       = (InvoiceDB.GetByID(refund.Invoice.InvoiceID).ReceiptsTotal).ToString();
            lblTotal.Visible   = false;
            lblReason.Visible  = false;
            lblComment.Visible = false;
        }
        else
        {
            lblTotal.Text              = refund.Total.ToString();
            lblReason.Text             = refund.RefundReason.Descr;
            lblComment.Text            = refund.Comment;
            amountReceiptedRow.Visible = false;
            txtTotal.Visible           = false;
            ddlRefundReason.Visible    = false;
            txtComment.Visible         = false;
        }



        if (isEditMode)
        {
            btnSubmit.Text = "Update Details";
        }
        else // is view mode
        {
            btnSubmit.Visible = false;
            btnCancel.Text    = "Close";
        }
    }
        public void TestListInvoiceDetailsForInvoice()
        {
            InvoiceDB db = new InvoiceDB();
            Invoice i = db.Invoices.First();
            ((IObjectContextAdapter)db).ObjectContext.Detach(i); //http://stackoverflow.com/questions/4168073/entity-framework-code-first-no-detach-method-on-dbcontext
            Assert.NotNull(i);

            InvoiceDetailsController idc = new InvoiceDetailsController();
            System.Web.Mvc.PartialViewResult result = idc.IndexByInvoice(i.InvoiceID);

            Assert.IsInstanceOf(typeof(List<InvoiceDetails>), result.ViewData.Model);
        }
        public void TestAddInvoice()
        {
            InvoiceController ic = new InvoiceController();

            //load first customer by calling DBcontext
            InvoiceDB db = new InvoiceDB();
            Customer c = db.Customers.First();
            ((IObjectContextAdapter)db).ObjectContext.Detach(c); //http://stackoverflow.com/questions/4168073/entity-framework-code-first-no-detach-method-on-dbcontext
            Assert.NotNull(c);

            Invoice i = new Invoice();
            i.CustomerID = c.CustomerID;
            i.Customer = c;
            i.AdvancePaymentTax = 10;
            i.Notes = "Invoice notes";
            i.TimeStamp = DateTime.Now;
            i.DueDate = DateTime.Now.AddDays(90);
            i.Paid = false;
            i.Name = "Test invoice";
         
            System.Web.Mvc.ActionResult resultAdd = ic.Create(i);

            Assert.IsInstanceOf(typeof(System.Web.Mvc.ViewResult), resultAdd);
        }
        public override bool ValidateUser(string username, string password)
        {
            InvoiceDB db = new InvoiceDB();
            var user = (from u in db.Users
                        where u.Login == username && u.Password == password
                        select u).FirstOrDefault();

            LoginUser = user;
            return (user != null);
        }
        public override System.Web.Security.MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out System.Web.Security.MembershipCreateStatus status)
        {
            InvoiceDB db = new InvoiceDB();
            User usr = new User();
            usr.Name = username;
            usr.Password = password;
            usr.Email = email;
            usr.Enabled = true;
            usr.Login = username;

            db.Users.Add(usr);

            try
            {
                db.SaveChanges();
            }
            catch (Exception e)
            {

                status = System.Web.Security.MembershipCreateStatus.UserRejected;
            }

            status = System.Web.Security.MembershipCreateStatus.Success;

            return null;
        }
        public override bool ValidateUser(string username, string password)
        {
            Database.SetInitializer(new EntitiesContextInitializer());

            InvoiceDB db = new InvoiceDB();
            var user = (from u in db.Users
                        where u.Login == username && u.Password == password
                        select u).FirstOrDefault();

            return (user != null);
        }