示例#1
0
        public async Task <bool> StoreNewEstimateLineAsync(int EstimateId, EstimateLine EstimateLine)
        {
            EstimateLine.EstimateId = EstimateId;

            _context.EstimateLines.Add(EstimateLine);
            return((await _context.SaveChangesAsync()) > 0);
        }
示例#2
0
 protected void Page_Init(object sender, EventArgs e)
 {
     ctx = new AriClinicContext("AriClinicContext");
     // security control, it must be a user logged
     if (Session["User"] == null)
     {
         Response.Redirect("Default.aspx");
     }
     else
     {
         user = CntAriCli.GetUser((Session["User"] as User).UserId, ctx);
         Process proc = (from p in ctx.Processes
                         where p.Code == "Estimate"
                         select p).FirstOrDefault <Process>();
         per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
         btnAccept.Visible = per.Modify;
     }
     //
     LoadComboInsurance();
     //
     if (Request.QueryString["EstimateId"] != null)
     {
         estId = Int32.Parse(Request.QueryString["EstimateId"]);
         est   = CntAriCli.GetEstimate(estId, ctx);
     }
     //
     if (Request.QueryString["EstimateLineId"] != null)
     {
         estlId = Int32.Parse(Request.QueryString["EstimateLineId"]);
         estl   = CntAriCli.GetEstimateLine(estlId, ctx);
         LoadData(estl);
     }
 }
示例#3
0
 protected void UnloadData(EstimateLine estl)
 {
     estl.Description      = txtDescription.Text;
     estl.Amount           = (decimal)txtAmount.Value;
     estl.Discount         = decimal.Parse(txtDiscount.Text);
     estl.InsuranceService = CntAriCli.GetInsuranceService(int.Parse(rdcInsuranceService.SelectedValue), ctx);
     if (est != null)
     {
         estl.Estimate = est;
     }
 }
示例#4
0
 protected bool CreateChange()
 {
     if (!DataOk())
     {
         return(false);
     }
     if (estl == null)
     {
         estl = new EstimateLine();
         UnloadData(estl);
         ctx.Add(estl);
     }
     else
     {
         estl = CntAriCli.GetEstimateLine(estlId, ctx);
         UnloadData(estl);
     }
     ctx.SaveChanges();
     return(true);
 }
示例#5
0
    protected void LoadData(EstimateLine estl)
    {
        txtEstimateLineId.Text = estl.EstimateLineId.ToString();
        txtDescription.Text    = estl.Description;
        txtAmount.Value        = (double)estl.Amount;
        txtDiscount.Text       = String.Format("{0:0.00}", estl.Discount);
        txtTotal.Value         = (double)(estl.Amount - estl.Discount);
        Insurance        iSelect = estl.InsuranceService.Insurance;
        InsuranceService iServ   = estl.InsuranceService;

        if (iSelect != null)
        {
            rdcbInsurance.SelectedValue = iSelect.InsuranceId.ToString();
        }
        //
        if (iServ != null)
        {
            rdcInsuranceService.Items.Clear();
            rdcInsuranceService.Items.Add(new RadComboBoxItem(iServ.Service.Name, iServ.InsuranceServiceId.ToString()));
            rdcInsuranceService.SelectedValue = iServ.InsuranceServiceId.ToString();
        }
    }
示例#6
0
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        // weonly process commands with a datasource (our image buttons)
        if (e.CommandSource == null)
        {
            return;
        }
        string typeOfControl = e.CommandSource.GetType().ToString();

        if (typeOfControl.Equals("System.Web.UI.WebControls.ImageButton"))
        {
            int         id   = 0;
            ImageButton imgb = (ImageButton)e.CommandSource;
            if (imgb.ID != "New" && imgb.ID != "Exit")
            {
                id = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][e.Item.OwnerTableView.DataKeyNames[0]];
            }
            switch (imgb.ID)
            {
            case "Select":
                break;

            case "Edit":
                break;

            case "Delete":
                EstimateLine estl = (from c in ctx.EstimateLines
                                     where c.EstimateLineId == id
                                     select c).FirstOrDefault <EstimateLine>();
                ctx.Delete(estl);
                ctx.SaveChanges();
                RadGrid1.DataSource = estimate.EstimateLines;
                RefreshTotal(estimate);
                RadGrid1.Rebind();
                break;
            }
        }
    }
示例#7
0
    protected void btnEstimate_Click(object sender, ImageClickEventArgs e)
    {
        if (!CreateChange())
        {
            return;
        }
        // check if
        string command = "";

        if (req.Estimates.Count > 0)
        {
            // There's a replay already
            Estimate est = req.Estimates[0];
            command = String.Format("EditEstimateRecord('{0}','{1}');", est.EstimateId, req.RequestId);
        }
        else
        {
            Estimate est = new Estimate();
            est.User         = user;
            est.FullName     = req.FullName;
            est.Request      = req;
            est.EstimateDate = DateTime.Now;
            if (req.Patient != null)
            {
                est.FullName = req.Patient.FullName;
            }
            else
            {
                est.FullName = req.FullName;
            }
            ctx.Add(est);
            ctx.SaveChanges();
            if (req.Service != null)
            {
                if (req.Patient != null && req.Patient.Customer != null && req.Patient.Customer.Policies.Count > 0)
                {
                    Policy           pol  = req.Patient.Customer.Policies[0];
                    InsuranceService inss = (from i in ctx.InsuranceServices
                                             where i.Insurance == pol.Insurance &&
                                             i.Service.ServiceId == req.Service.ServiceId
                                             select i).FirstOrDefault <InsuranceService>();
                    if (inss != null)
                    {
                        // estimate line
                        EstimateLine estl = new EstimateLine();
                        est.Comments          = "";
                        estl.Estimate         = est;
                        estl.InsuranceService = inss;
                        estl.Amount           = inss.Price;
                        estl.Discount         = 0;
                        estl.Description      = inss.Service.Name;
                        ctx.Add(estl);
                        est.Total = estl.Amount;
                        ctx.SaveChanges();
                    }
                }
            }
            command = String.Format("EditEstimateRecord('{0}','{1}');", est.EstimateId, req.RequestId);
        }
        // string command = "CloseAndRebind('')";
        RadAjaxManager1.ResponseScripts.Add(command);
    }
示例#8
0
 public async Task <bool> DeleteEstimateLine(EstimateLine EstimateLine)
 {
     _context.Remove(EstimateLine);
     return((await _context.SaveChangesAsync()) > 0);
 }
示例#9
0
        public async Task <bool> UpdateEstimateLineAsync(int EstimateId, EstimateLine EstimateLine)
        {
            EstimateLine.EstimateId = EstimateId;

            return((await _context.SaveChangesAsync()) > 0);
        }