Exemple #1
0
        public ActionResult Age(AgeCalculatorRequest request)
        {
            
            DateDifference age = request.DateOfBirth.DateDifference(DateTime.Now);

            return Json(new {Result = $"Age: {age.Years} Year(s) {age.Months} Month(s) {age.Weeks} Weeks {age.Days} Day(s) {age.Hours} Hour(s) {age.Minutes} Minutes {age.Seconds} Second(s)" });
        }
        private void dtpFechaNacimiento_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            //Calcula la edad
            if (dtpFechaNacimiento.Text != "")
            {
                int lEdad = CalcularEdad(DateTime.Parse(dtpFechaNacimiento.Text));

                if (lEdad == -1)
                {
                    ControlOperation.alertWarning("La fecha de nacimiento es mayor a la fecha de hoy, Ingrese correctamente la fecha de nacimiento");
                    dtpFechaNacimiento.Text = "";
                }
                else if (lEdad == -2)
                {
                    ControlOperation.alertWarning(
                        "La edad del niño es igual o mayor a 13 años, no se le puede registrar en el sistema");

                    mAgeBlock = true;
                }
                else
                {
                    DateDifference dateDifference = new DateDifference(dtpFechaNacimiento.SelectedDate.Value,
                                                                       DateTime.Now.Date);

                    if (dtpFechaNacimiento.SelectedDate != null)
                    {
                        lblEdad.Content = dateDifference.ToString();
                    }
                    //lblEdad.Content = lEdad.ToString();
                }
            }
        }
Exemple #3
0
        private void btn14gun_Click(object sender, RoutedEventArgs e)
        {
            DateTime test = DateTime.Now;

            test             = test.AddDays(14);
            txtSendDate.Text = DateDifference.RemoveHour(test);
        }
Exemple #4
0
        public ActionResult DanhSachChuong(int id, string name)
        {
            if (!CheckSS())
            {
                return(RedirectToAction("DangNhap", "User"));
            }
            else
            {
                var tentruyen = data.Truyens.SingleOrDefault(m => m.MaProject == id).TenProject;
                ViewBag.TenTruyen  = tentruyen;
                ViewBag.MaProject  = id;
                ViewBag.Tenbandich = name;
                //int pageNum = (page ?? 1);
                //int pageSize = 7;
                DAO.DaoChuongTruyen daoChuongTruyen = new DAO.DaoChuongTruyen();
                ViewBag.LoaiTrang = daoChuongTruyen.GetLoaiTrang();
                var listtruyen = data.ChuongTruyens.Where(m => m.MaProject == id && m.DaXoa == false).OrderByDescending(a => a.ThuTuChuong).ToList();
                List <ChuongTruyenDaTao> chuongtruyens = new List <ChuongTruyenDaTao>();

                foreach (var truyen in listtruyen)
                {
                    ChuongTruyenDaTao chuongtruyen1 = new ChuongTruyenDaTao();
                    chuongtruyen1.TenChuong = truyen.TenChuongTruyen;
                    DateTime Tgcn  = truyen.ThoiGianCapNhat;
                    var      month = new DateDifference(Tgcn, DateTime.Now);

                    chuongtruyen1.Thoigian = month.ToString();
                    chuongtruyen1.LuotXem  = truyen.LuotXem;
                    chuongtruyen1.MaChuong = truyen.MaChuongTruyen;
                    chuongtruyens.Add(chuongtruyen1);
                }
                return(View(chuongtruyens));
            }
        }
Exemple #5
0
        private void dTP_Born_ValueChanged(object sender, EventArgs e)
        {
            DateTime ToDate = DateTime.Now;

            DateDifference dDiff = new DateDifference(dTP_Born.Value, ToDate);

            lb_BirthDay.Text = dDiff.ToString("ปี", "เดือน", "วัน");
        }
Exemple #6
0
        private void button3_Click(object sender, EventArgs e)
        {
            string         date           = "11/01/1991";
            DateTime       dt             = Convert.ToDateTime(date);
            DateTime       dt2            = Convert.ToDateTime("07/03/2013");
            DateDifference dateDifference = new DateDifference(dt, dt2);

            MessageBox.Show(dateDifference.ToString());
        }
Exemple #7
0
        protected void TmpCopintGridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            Label lbempName = (Label)(e.Row.FindControl("lbempName"));

            if (lbempName != null)
            {
                lbempName.Text = (string)DataBinder.Eval(e.Row.DataItem, "profix_name") + (string)DataBinder.Eval(e.Row.DataItem, "emp_name") + "  " + (string)DataBinder.Eval(e.Row.DataItem, "emp_lname");
            }

            Label lbempChengDate = (Label)(e.Row.FindControl("lbempChengDate"));

            if (lbempChengDate != null)
            {
                lbempChengDate.Text = dBScript.convertDatelongThai((string)DataBinder.Eval(e.Row.DataItem, "tmp_cpoint_date"));
            }

            // เหลือเวลา
            Label lbempAgeWork = (Label)(e.Row.FindControl("lbCountdown"));

            if (lbempAgeWork != null)
            {
                string[]       data      = DataBinder.Eval(e.Row.DataItem, "tmp_cpoint_date").ToString().Split('-');
                DateTime       dateStart = DateTime.ParseExact(data[0] + "-" + data[1] + "-" + (int.Parse(data[2]) - 543), "dd-MM-yyyy", CultureInfo.InvariantCulture);
                DateDifference dDiff     = new DateDifference(dateStart);
                lbempAgeWork.Text = dDiff.ToString();
            }

            LinkButton btnConfirm = (LinkButton)(e.Row.FindControl("btnConfirm"));
            Label      txtConfirm = (Label)(e.Row.FindControl("txtConfirm"));

            if (btnConfirm != null)
            {
                btnConfirm.CommandName = DataBinder.Eval(e.Row.DataItem, "tmp_cpoint_id").ToString();
                if (DataBinder.Eval(e.Row.DataItem, "tmp_cpoint_status_approve").ToString() == "0")
                {
                    btnConfirm.Visible = true;
                    txtConfirm.Visible = false;
                }
                else
                {
                    btnConfirm.Visible = false;
                    txtConfirm.Visible = true;
                }
            }

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                try
                {
                    ((LinkButton)e.Row.Cells[6].Controls[0]).OnClientClick = "return confirmDelete(this);";
                }
                catch { }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (idHCP == 0)
            {
                divResumenPaciente.Attributes["class"] += " ui-helper-hidden";
            }
            else
            {
                AprHistoriaClinicaPerinatal oHCP = new AprHistoriaClinicaPerinatal(idHCP);
                SysPaciente oPaciente            = new SysPaciente(oHCP.IdPaciente);
                int         idPaciente           = oHCP.IdPaciente;
                if (!oPaciente.IsNew)
                {
                    DateDifference oEdad = new DateDifference(oPaciente.FechaNacimiento, DateTime.Today);
                    edad                   = oEdad;
                    ltPaciente.Text        = String.Format("{0}, {1}", oPaciente.Apellido, oPaciente.Nombre);
                    ltDocumentoUnico.Text  = oPaciente.NumeroDocumento.ToString();
                    ltFechaNacimiento.Text = oPaciente.FechaNacimiento.ToShortDateString();
                    ltEdad.Text            = oEdad.ToString();
                    semanas                = oEdad.Weeks;
                    ltObraSocial.Text      = oPaciente.SysObraSocial.Nombre;
                    ltSexo.Text            = oPaciente.SysSexo.Nombre;
                    //ltCronico.Text = oPaciente.Cronico ? "SI" : "NO";

                    //traigo el numero de historia clinica en el efector
                    int       efector = SSOHelper.CurrentIdentity.IdEfector;
                    DataTable dt      = SPs.SysGetPacientesHC(oPaciente.NumeroDocumento, efector).GetDataSet().Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        if (!string.IsNullOrEmpty(dt.Rows[0][9].ToString()))
                        {
                            int numeroHistoria = Convert.ToInt32(dt.Rows[0][9]);
                            ltHC.Text = numeroHistoria.ToString();
                        }
                    }

                    lkEditar.NavigateUrl = "~/Paciente/PacienteEdit.aspx?id=" + idPaciente.ToString();
                    if (oEdad.Years > 6)
                    {
                        //mayor de 6 años, oculto el link de control del menor
                        lkControlmenor.Visible = false;
                    }
                    else
                    {
                        //Menor o igual a 6 años, muestro el link del controles del menor
                        lkControlmenor.NavigateUrl = String.Format("~/ControlMenor/?idPaciente={0}", idPaciente);
                    }
                }
                else
                {
                    divResumenPaciente.Attributes["class"] += " ui-helper-hidden";
                }
            }
        }
    public static string DateTimeToWord(DateTime DateTimeString)
    {
        if ((DateTimeString == null))
        {
            return("...");
        }
        long value; string str = "";

        if (DateDifference.DateDiff(DateDifference.DateInterval.Minute, DateTimeString, DateTime.Now) <= 2)
        {
            str = "now";
        }
        else if (DateDifference.DateDiff(DateDifference.DateInterval.Minute, DateTimeString, DateTime.Now) <= 60)
        {
            value = DateDifference.DateDiff(DateDifference.DateInterval.Minute, DateTimeString, DateTime.Now);
            str   = value + " min" + (value > 1 ? "s " : " ") + "ago";
        }
        else if (DateDifference.DateDiff(DateDifference.DateInterval.Hour, DateTimeString, DateTime.Now) <= 24)
        {
            value = DateDifference.DateDiff(DateDifference.DateInterval.Hour, DateTimeString, DateTime.Now);
            str   = value + " hr" + (value > 1 ? "s " : " ") + "ago";
        }
        else if (DateDifference.DateDiff(DateDifference.DateInterval.Day, DateTimeString, DateTime.Now) == 1)
        {
            value = DateDifference.DateDiff(DateDifference.DateInterval.Day, DateTimeString, DateTime.Now);
            str   = " yst";
        }
        else if (DateDifference.DateDiff(DateDifference.DateInterval.Day, DateTimeString, DateTime.Now) <= 7)
        {
            value = DateDifference.DateDiff(DateDifference.DateInterval.Day, DateTimeString, DateTime.Now);
            str   = value + " day" + (value > 1 ? "s " : " ") + "ago";
        }
        else if (DateDifference.DateDiff(DateDifference.DateInterval.Weekday, DateTimeString, DateTime.Now) <= 4)
        {
            value = DateDifference.DateDiff(DateDifference.DateInterval.Weekday, DateTimeString, DateTime.Now);
            str   = value + " wk" + (value > 1 ? "s " : " ") + "ago";
        }
        else if (DateDifference.DateDiff(DateDifference.DateInterval.Month, DateTimeString, DateTime.Now) <= 12)
        {
            value = DateDifference.DateDiff(DateDifference.DateInterval.Month, DateTimeString, DateTime.Now);
            str   = value + " mth" + (value > 1 ? "s " : " ") + "ago";
        }
        else if (DateDifference.DateDiff(DateDifference.DateInterval.Year, DateTimeString, DateTime.Now) >= 1)
        {
            value = DateDifference.DateDiff(DateDifference.DateInterval.Year, DateTimeString, DateTime.Now);
            str   = value + " yr" + (value > 1 ? "s " : " ") + "ago";
        }

        return(str);
    }
Exemple #10
0
        private void btnCalculateOutstanding_Click(object sender, EventArgs e)
        {
            if (Validation.ValidateCombo(ref cmbClients))
            {
                Client current = (Client)bind1.Current;

                List <Contract> contracts = new Contract().GetAllContracts(current.ClientIdentifier);
                if (contracts.Count > 0)
                {
                    foreach (Contract item in contracts)
                    {
                        if (item.DateOfIssue.AddMonths(item.TermDuration) > DateTime.UtcNow)
                        {
                            ServiceLevel                  sl = new ServiceLevel().GetServiceLevels(item.SLevel.Level)[0];
                            List <ContractProducts>       cp = new ContractProducts(item, new Product()).GetContractProducts();
                            List <ContractConfigurations> cc = new ContractConfigurations(item).GetContractConfigurations();
                            List <Billing>                b  = new Billing(current, DateTime.UtcNow, 0, 0).GetClientBilling();
                            int monthsLeft = DateDifference.GetMonthDifference(item.DateOfIssue, item.DateOfIssue.AddMonths(item.TermDuration));
                            if (monthsLeft > 0)
                            {
                                chcDiffPaid.Visible = true;
                                int    monthsPaid         = DateDifference.GetMonthDifference(item.DateOfIssue, DateTime.UtcNow);
                                double serviceFeePaid     = monthsPaid * sl.MonthlyCost;
                                double sumProductCost     = (from cProd in cp select cProd.ContractProducts_Product.BasePrice).Sum();
                                double sumAddCosts        = (from cConf in cc select cConf.ContractConfigurations_Configuration.AddCost).Sum();
                                double sumProductCostPaid = (from bProd in b select bProd.AmountPaid).Sum() - serviceFeePaid;
                                outstandingAmount = (sumProductCost + sumAddCosts) - sumProductCostPaid;
                            }
                            else
                            {
                                chcDiffPaid.Visible = false;
                            }
                            txtOutstanding.Text             = "R" + outstandingAmount.ToString();
                            txtOutstanding.Visible          = true;
                            lblOutstanding.Visible          = true;
                            btnCalculateOutstanding.Visible = false;
                            break;
                        }
                    }
                }
                else
                {
                    MessageBoxShower.ShowInfo("This client does not have any active contracts.", "Cannot Cancel contract");
                    txtOutstanding.Visible = false;
                    lblOutstanding.Visible = false;
                    chcDiffPaid.Visible    = false;
                }
            }
        }
Exemple #11
0
        private void DetailStudent_Loaded(object sender, RoutedEventArgs e)
        {
            frame = ((MainWindow)Application.Current.MainWindow).ConFrame;
            ChangesDetection();

            if (detailType == DetailType.Add)
            {
            }

            if (detailType == DetailType.Edit)
            {
                List <Book> list = new List <Book>();
                try
                {
                    if (IsExcelData != true)
                    {
                        list = bookManager.GetBooksOfStudent(student.Identity);
                        lblBookCount.Content = "Öğrenci kütüphaneden toplam " + student.StudentBookCount + " adet kitap almış.";
                    }
                }
                catch (Exception)
                {
                }


                booksOfStudent.Children.Clear();

                foreach (var item in list)
                {
                    Label label = new Label()
                    {
                        Height = 40,
                        VerticalContentAlignment = VerticalAlignment.Center,
                        Margin   = new Thickness(0, 0, 0, 10),
                        FontSize = 16,
                    };
                    label.Content = DateDifference.RemoveHour(item.DateOfIssue)
                                    + " tarihinde > \"" + item.BookName + "\" adlı kitap";
                    booksOfStudent.Children.Add(label);
                }

                LoadDatas();
            }
        }
Exemple #12
0
        private void ShowData()
        {
            if (detailType == DetailType.Edit)
            {
                try
                {
                    lbldetail.Content  = DateDifference.RemoveHour(book.DateOfIssue) + " Kitap şurada: ";
                    lbldetail.Content += studentManager.Get(book.BookLocation).StudentName;
                }
                catch (Exception)
                {
                }
                lblDetailTitle.Content = book.BookName;
                txt_isim.Text          = book.BookName;
                txt_tur.Text           = book.BookType;
                try
                {
                    txt_raf.Text = book.BookBarcode.ToString();
                }
                catch (Exception)
                {
                }
                txt_yazar.Text       = book.BookAuthor;
                txt_yayinci.Text     = book.BookPublisher;
                txt_yayintarihi.Text = DateDifference.RemoveHour(book.BookReleaseDate);
                txtSendDate.Text     = DateDifference.RemoveHour(book.DateOfCommitment);
            }

            if (KeySet.Yetki == false)
            {
                btnDelete.Visibility = Visibility.Hidden;
                btnSave.Visibility   = Visibility.Hidden;

                foreach (var item in anapanel.Children)
                {
                    if (item is TextBox)
                    {
                        TextBox ann = item as TextBox;
                        ann.IsHitTestVisible = true;
                        ann.IsReadOnly       = true;
                    }
                }
            }
        }
Exemple #13
0
        public static DateDifference DateDifference(this DateTime fromDate, DateTime toDate)
        {
            if (fromDate == DateTime.MinValue)
            {
                throw new Exception("Please enter valid date");
            }
            if (toDate < fromDate)
            {
                throw new Exception("To date should be greater than From date");
            }
            DateDifference difference = new DateDifference();

            difference.Years = new DateTime(toDate.Subtract(fromDate).Ticks).Year - 1;
            DateTime pastYearDate = fromDate.AddYears(difference.Years);
            int      months       = 0;

            for (int i = 1; i <= 12; i++)
            {
                if (pastYearDate.AddMonths(i) == toDate)
                {
                    months = i;
                    break;
                }
                else if (pastYearDate.AddMonths(i) >= toDate)
                {
                    months = i - 1;
                    break;
                }
            }
            difference.Months = months;
            int days = toDate.Subtract(pastYearDate.AddMonths(months)).Days;

            difference.Weeks   = days / 7;
            difference.Days    = days % 7;
            difference.Hours   = toDate.Subtract(pastYearDate).Hours;
            difference.Minutes = toDate.Subtract(pastYearDate).Minutes;
            difference.Seconds = toDate.Subtract(pastYearDate).Seconds;
            return(difference);
        }
Exemple #14
0
        private void btnFinish_Click(object sender, EventArgs e)
        {
            if (contract.InsertContract() && SubmitAllProducts() && SubmitAllConfigs())
            {
                MessageBoxShower.ShowInfo("The Contract has been recorded successfully.", "Success!");

                Client          current           = client;
                double          outstandingAmount = 0;
                List <Contract> contracts         = new Contract().GetAllContracts(current.ClientIdentifier);
                if (contracts.Count > 0)
                {
                    foreach (Contract item in contracts)
                    {
                        if (item.DateOfIssue.AddMonths(item.TermDuration) > DateTime.UtcNow)
                        {
                            ServiceLevel                  sl = new ServiceLevel().GetServiceLevels(item.SLevel.Level)[0];
                            List <ContractProducts>       cp = new ContractProducts(item, new Product()).GetContractProducts();
                            List <ContractConfigurations> cc = new ContractConfigurations(item).GetContractConfigurations();
                            List <Billing>                b  = new Billing(current, DateTime.UtcNow, 0, 0).GetClientBilling();
                            int monthsLeft = DateDifference.GetMonthDifference(item.DateOfIssue, item.DateOfIssue.AddMonths(item.TermDuration));
                            if (monthsLeft > 0)
                            {
                                int    monthsPaid         = DateDifference.GetMonthDifference(item.DateOfIssue, DateTime.UtcNow);
                                double serviceFeePaid     = monthsPaid * sl.MonthlyCost;
                                double sumProductCost     = (from cProd in cp select cProd.ContractProducts_Product.BasePrice).Sum();
                                double sumAddCosts        = (from cConf in cc select cConf.ContractConfigurations_Configuration.AddCost).Sum();
                                double sumProductCostPaid = (from bProd in b select bProd.AmountPaid).Sum() - serviceFeePaid;
                                outstandingAmount = (sumProductCost + sumAddCosts) - sumProductCostPaid;
                            }
                            Billing bill = new Billing(client, DateTime.UtcNow, outstandingAmount, 0);
                            bill.InsertBilling();
                        }
                    }
                }
            }
            this.Close();
        }
        private void fillData()
        {
            DataTable lDtHistorialMedico = new DataTable();

            ControlDePacientes.Dal.Paciente lPaciente = new Paciente();

            lDtHistorialMedico = lPaciente.GetPacienteByRegistroMedico(txtIdPaciente.Text);

            if (lDtHistorialMedico.Rows.Count > 0)
            {
                txtIdPaciente.IsEnabled     = false;
                txtNombrePaciente.Text      = (string)lDtHistorialMedico.Rows[0]["Nombre"];
                txtNombrePaciente.IsEnabled = false;
                if (lDtHistorialMedico.Rows[0]["Apellido"].ToString() != "" || lDtHistorialMedico.Rows[0]["SegundoApellido"].ToString() != "")
                {
                    txtApellidoPaciente.Text = (string)lDtHistorialMedico.Rows[0]["Apellido"] + " " + (string)lDtHistorialMedico.Rows[0]["SegundoApellido"];
                }
                else
                {
                    txtApellidoPaciente.Text = "";
                }
                txtApellidoPaciente.IsEnabled = false;
                if (lDtHistorialMedico.Rows[0]["SexoName"].ToString() != "")
                {
                    txtSexo.Text = (string)lDtHistorialMedico.Rows[0]["SexoName"];
                }
                else
                {
                    txtSexo.Text = "";
                }
                txtSexo.IsEnabled = false;
                //lblEdad.Content = Convert.ToString( CalcularEdad(DateTime.Parse(Convert.ToString(lDtHistorialMedico.Rows[0]["FechaNacimiento"]))));
                if (lDtHistorialMedico.Rows[0]["FechaNacimiento"].ToString() != "")
                {
                    DateDifference dateDifference =
                        new DateDifference(DateTime.Parse(Convert.ToString(lDtHistorialMedico.Rows[0]["FechaNacimiento"])),
                                           DateTime.Now.Date);
                    lblEdad.Content = dateDifference.ToString();
                }
                else
                {
                    lblEdad.Content = "";
                }

                if (lDtHistorialMedico.Rows[0]["NombrePadre"].ToString() != "")
                {
                    txtNombrePadre.Text = (string)lDtHistorialMedico.Rows[0]["NombrePadre"];
                }
                else
                {
                    txtNombrePadre.Text = "";
                }
                txtNombrePadre.IsEnabled = false;
                if (lDtHistorialMedico.Rows[0]["NombreMadre"].ToString() != "")
                {
                    txtNombreMadre.Text = (string)lDtHistorialMedico.Rows[0]["NombreMadre"];
                }
                else
                {
                    txtNombreMadre.Text = "";
                }
                txtNombreMadre.IsEnabled = false;
                if (lDtHistorialMedico.Rows[0]["Direccion"].ToString() != "")
                {
                    txtDireccion.Text = (string)lDtHistorialMedico.Rows[0]["Direccion"]; //unir con municipio y departamento
                }
                else
                {
                    txtDireccion.Text = "";
                }
                txtDireccion.IsEnabled = false;
                if (lDtHistorialMedico.Rows[0]["FotoPath"] == DBNull.Value || (string)lDtHistorialMedico.Rows[0]["FotoPath"] == "")
                {
                }
                else
                {
                    ControlOperation.LoadImageFromDB((byte[])lDtHistorialMedico.Rows[0]["FotoPaciente"], imgPaciente);
                }

                expDetalle.IsEnabled  = true;
                expDetalle.IsExpanded = true;
                wrpButtons.Visibility = Visibility.Visible;
            }
        }
Exemple #16
0
        private void fillData()
        {
            DataTable lDtPaciente = new DataTable();

            ControlDePacientes.Dal.Paciente lPaciente = new Paciente();
            //lDtPaciente = lPaciente.GetPacienteById(Convert.ToInt32(txtIdPaciente.Text));
            lDtPaciente = lPaciente.GetPacienteByRegistroMedico(txtIdPaciente.Text);

            if (lDtPaciente.Rows.Count > 0)
            {
                mIdPaciente = (int)lDtPaciente.Rows[0]["IdPaciente"];

                DataTable lDtVerifyHistorial = new DataTable();
                ControlDePacientes.Dal.HistorialMedico lHistorialMedicoVerify = new HistorialMedico();
                lDtVerifyHistorial = lHistorialMedicoVerify.HistorialMedicoVerify(mIdPaciente, 10); //10 es Iniciado

                if (lDtVerifyHistorial.Rows.Count > 0)
                {
                    txtIdPaciente.IsEnabled       = false;
                    txtNombrePaciente.Text        = (string)lDtPaciente.Rows[0]["Nombre"];
                    txtNombrePaciente.IsEnabled   = false;
                    txtApellidoPaciente.Text      = lDtPaciente.Rows[0]["Apellido"].ToString() != "" || lDtPaciente.Rows[0]["SegundoApellido"].ToString() != "" ? (string)lDtPaciente.Rows[0]["Apellido"] + " " + (string)lDtPaciente.Rows[0]["SegundoApellido"] : "";
                    txtApellidoPaciente.IsEnabled = false;
                    txtSexo.Text      = lDtPaciente.Rows[0]["SexoName"].ToString() != "" ? (string)lDtPaciente.Rows[0]["SexoName"] : "";
                    txtSexo.IsEnabled = false;
                    if (lDtPaciente.Rows[0]["FechaNacimiento"].ToString() != "")
                    {
                        DateDifference dateDifference = new DateDifference(DateTime.Parse(Convert.ToString(lDtPaciente.Rows[0]["FechaNacimiento"])), DateTime.Now.Date);
                        lblEdad.Content = dateDifference.ToString();
                    }
                    else
                    {
                        lblEdad.Content = "";
                    }

                    txtNombrePadre.Text      = lDtPaciente.Rows[0]["NombrePadre"].ToString() != "" ? (string)lDtPaciente.Rows[0]["NombrePadre"] : "";
                    txtNombrePadre.IsEnabled = false;
                    txtNombreMadre.Text      = lDtPaciente.Rows[0]["NombreMadre"].ToString() != "" ? (string)lDtPaciente.Rows[0]["NombreMadre"] : "";
                    txtNombreMadre.IsEnabled = false;
                    txtDireccion.Text        = lDtPaciente.Rows[0]["Direccion"].ToString() != "" ? (string)lDtPaciente.Rows[0]["Direccion"] : "";
                    txtDireccion.IsEnabled   = false;


                    if (lDtPaciente.Rows[0]["FotoPath"] == DBNull.Value || (string)lDtPaciente.Rows[0]["FotoPath"] == "")
                    {
                    }
                    else
                    {
                        ControlOperation.LoadImageFromDB((byte[])lDtPaciente.Rows[0]["FotoPaciente"], imgPaciente);
                    }

                    //   imgPaciente.Source = new BitmapImage(new Uri((string)lDtPaciente.Rows[0]["FotoPath"]));

                    expExamenFisico.IsEnabled  = true;
                    expExamenFisico.IsExpanded = true;
                    wrpButtons.Visibility      = Visibility.Visible;

                    //lleno el examen fisico
                    txtMotivoConsulta.Text = lDtVerifyHistorial.Rows[0]["MotivoConsulta"].ToString() != "" ? (string)lDtVerifyHistorial.Rows[0]["MotivoConsulta"] : "";
                    txtPA.Text             = lDtVerifyHistorial.Rows[0]["PresionArterial"].ToString() != "" ? Convert.ToString(lDtVerifyHistorial.Rows[0]["PresionArterial"]) : "";
                    if (lDtVerifyHistorial.Rows[0]["CodServicio"].ToString() != "")
                    {
                        cmbServicio.SelectedValue = (int)lDtVerifyHistorial.Rows[0]["CodServicio"];
                    }
                    else
                    {
                        cmbServicio.SelectedIndex = 0;
                    }
                    txtFC.Text           = lDtVerifyHistorial.Rows[0]["FrecuenciaCardiaca"].ToString() != "" ? Convert.ToString(lDtVerifyHistorial.Rows[0]["FrecuenciaCardiaca"]) : "";
                    txtRX.Text           = lDtVerifyHistorial.Rows[0]["RayosX"].ToString() != "" ? Convert.ToString(lDtVerifyHistorial.Rows[0]["RayosX"]) : "";
                    txtFR.Text           = lDtVerifyHistorial.Rows[0]["FrecuenciaRespiratora"].ToString() != "" ? Convert.ToString(lDtVerifyHistorial.Rows[0]["FrecuenciaRespiratora"]) : "";
                    txtTemp.Text         = lDtVerifyHistorial.Rows[0]["Temperatura"].ToString() != "" ? Convert.ToString(lDtVerifyHistorial.Rows[0]["Temperatura"]) : "";
                    txtCC.Text           = lDtVerifyHistorial.Rows[0]["CC"].ToString() != "" ? Convert.ToString(lDtVerifyHistorial.Rows[0]["CC"]) : "";
                    txtPeso.Text         = lDtVerifyHistorial.Rows[0]["Peso"].ToString() != "" ? Convert.ToString(lDtVerifyHistorial.Rows[0]["Peso"]) : "";
                    txtTalla.Text        = lDtVerifyHistorial.Rows[0]["Talla"].ToString() != "" ? Convert.ToString(lDtVerifyHistorial.Rows[0]["Talla"]) : "";
                    txtMC.Text           = lDtVerifyHistorial.Rows[0]["MasaCorporal"].ToString() != "" ? Convert.ToString(lDtVerifyHistorial.Rows[0]["MasaCorporal"]) : "";
                    txtTE.Text           = lDtVerifyHistorial.Rows[0]["TE"].ToString() != "" ? Convert.ToString(lDtVerifyHistorial.Rows[0]["TE"]) : "";
                    txtPE.Text           = lDtVerifyHistorial.Rows[0]["PE"].ToString() != "" ? Convert.ToString(lDtVerifyHistorial.Rows[0]["PE"]) : "";
                    txtPesoTalla.Text    = lDtVerifyHistorial.Rows[0]["PesoTalla"].ToString() != "" ? Convert.ToString(lDtVerifyHistorial.Rows[0]["PesoTalla"]) : "";
                    txtSaturacion.Text   = lDtVerifyHistorial.Rows[0]["SaturacionO2"].ToString() != "" ? Convert.ToString(lDtVerifyHistorial.Rows[0]["SaturacionO2"]) : "";
                    txtExamenFisico.Text = lDtVerifyHistorial.Rows[0]["ExamenFisico"].ToString() != "" ? (string)lDtVerifyHistorial.Rows[0]["ExamenFisico"] : "";
                    txtAntecedentes.Text = lDtVerifyHistorial.Rows[0]["AntecedentesImportancia"].ToString() != "" ? (string)lDtVerifyHistorial.Rows[0]["AntecedentesImportancia"] : "";
                }
                else
                {
                    ControlOperation.alertWarning("El paciente no tiene un historial nuevo, debe registrarse en Admisión");
                }
            }
        }
        public void HabilitarBotonesConsulta(SysPaciente p, int idturno)
        {
            HfidPaciente.Value = p.IdPaciente.ToString();
            HfDNI.Value        = p.NumeroDocumento.ToString();
            HfidEfector.Value  = SSOHelper.CurrentIdentity.IdEfector.ToString();
            HfidTurno.Value    = idturno.ToString();

            string strIdHospital = SSOHelper.Configuration["idHospital"] as string;

            if (strIdHospital != "0")
            {
                BtnLabo.Visible = false; BtnVerInter.Visible = false; BtnNvaInter.Visible = false; BtnEventos.Visible = false; BtnControl.Visible = false;
                ////////////////77
                BtnEventosHospital.Visible = true;
                BtnLaboHospital.Visible    = true;
                BtnPedidoPAP.Visible       = false;
            }
            else
            {
                //consultar si tiene algun laboratorio, habilitar para ingresar
                BtnLaboHospital.Visible = false;

                LabResultadoEncabezado conLab = new SubSonic.Select()
                                                .From(Schemas.LabResultadoEncabezado)
                                                .Where(LabResultadoEncabezado.Columns.NumeroDocumento).IsEqualTo(p.NumeroDocumento)
                                                .ExecuteSingle <LabResultadoEncabezado>();
                if (conLab != null)
                {
                    BtnLabo.Visible = true;
                }
                else
                {
                    BtnLabo.Visible = false;
                }

                //consultar si tiene alguna interconsulta, habilitar para ingresa
                //IcoInterconsultum conInterconsulta = new SubSonic.Select()
                //      .From(Schemas.IcoInterconsultum)
                //        .Where(IcoInterconsultum.Columns.IdPaciente).IsEqualTo(p.IdPaciente)
                //          .ExecuteSingle<IcoInterconsultum>();
                //if (conInterconsulta != null)
                //    BtnVerInter.Visible = true;
                //else
                //    BtnVerInter.Visible = false;

                DataTable dtInterconsultas = new DataTable();
                dtInterconsultas = SPs.IcoVerificarSiTieneInterconsultas(p.IdPaciente).GetDataSet().Tables[0];

                if (dtInterconsultas.Rows.Count != 0)
                {
                    BtnVerInter.Visible = true;
                }
                else
                {
                    BtnVerInter.Visible = false;
                }

                //Habilito las consultas a los demas modulos
                //Si es femenino podra ingresar al modulo del control perinatal
                if (p.IdSexo == 2) //Femenino
                {
                    BtnControl.Visible = true;
                    BtnMamas.Visible   = true;
                    ///pongo visible Pedido de PAP y HPV solo para nivel central
                    DateDifference oEdad = new DateDifference(p.FechaNacimiento, DateTime.Now);
                    if ((oEdad.Years > 30) && (oEdad.Years < 64))
                    {
                        BtnPedidoPAP.Visible = true;
                    }
                }

                else
                {
                    BtnControl.Visible = false;
                    BtnMamas.Visible   = false;
                }
            }

            if ((!BtnPedidoPAP.Visible) && (!BtnMamas.Visible))
            {
                pnlPrestaciones.Visible = false;
            }
            /// Pacientes para VGI
            DateDifference oEdadGeriatrico = new DateDifference(p.FechaNacimiento, DateTime.Now);

            if (oEdadGeriatrico.Years > 60) // definir la edad de pacientes geriatricos para VGI.
            {
                BtnNuevoVGI.Visible = true;
            }
            else
            {
                BtnNuevoVGI.Visible = false;
            }
            ////
        }
Exemple #18
0
        protected void ClaimGridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            LinkButton lbCpoint = (LinkButton)(e.Row.FindControl("lbCpoint"));

            if (lbCpoint != null)
            {
                lbCpoint.CommandName = (string)DataBinder.Eval(e.Row.DataItem, "claim_id");
            }

            LinkButton lbNoteCom = (LinkButton)(e.Row.FindControl("lbNoteCom"));

            if (lbNoteCom != null)
            {
                lbNoteCom.CommandName = (string)DataBinder.Eval(e.Row.DataItem, "claim_id");
            }


            LinkButton lbEquipment = (LinkButton)(e.Row.FindControl("lbEquipment"));

            if (lbEquipment != null)
            {
                lbEquipment.CommandName = (string)DataBinder.Eval(e.Row.DataItem, "claim_id");
                lbEquipment.ToolTip     = (string)DataBinder.Eval(e.Row.DataItem, "claim_equipment");;
            }


            Label lbCpointDate = (Label)(e.Row.FindControl("lbCpointDate"));

            if (lbCpointDate != null)
            {
                lbCpointDate.Text = function.ConvertDateShortThai((string)DataBinder.Eval(e.Row.DataItem, "claim_cpoint_date"));
            }

            Label lbStartDate = (Label)(e.Row.FindControl("lbStartDate"));

            if (lbStartDate != null)
            {
                lbStartDate.Text = function.ConvertDateShortThai((string)DataBinder.Eval(e.Row.DataItem, "claim_start_date"));
            }

            Label lbDay = (Label)(e.Row.FindControl("lbDay"));

            if (lbDay != null)
            {
                string[]       data      = DataBinder.Eval(e.Row.DataItem, "claim_start_date").ToString().Split('-');
                DateTime       dateStart = DateTime.ParseExact(data[0] + "-" + data[1] + "-" + (int.Parse(data[2]) - 543), "dd-MM-yyyy", CultureInfo.InvariantCulture);
                DateDifference differnce = new DateDifference(dateStart);

                if (differnce.ToString() == "")
                {
                    lbDay.CssClass = "badge badge-danger";
                    lbDay.Text     = "NEW!!";
                }
                else
                {
                    lbDay.Text = differnce.ToString();
                }
            }

            Label lbStatus = (Label)(e.Row.FindControl("lbStatus"));

            if (lbStatus != null)
            {
                lbStatus.CssClass = "badge badge-" + (string)DataBinder.Eval(e.Row.DataItem, "status_alert");
            }

            LinkButton printReport1 = (LinkButton)(e.Row.FindControl("printReport1"));

            if (printReport1 != null)
            {
                printReport1.CommandName = (string)DataBinder.Eval(e.Row.DataItem, "claim_id");
                //printReport1.OnClientClick = "document.forms[0].target ='_blank';";
                //printReport1.t
            }

            LinkButton printReport2 = (LinkButton)(e.Row.FindControl("printReport2"));

            if (printReport2 != null)
            {
                printReport2.CommandName = (string)DataBinder.Eval(e.Row.DataItem, "claim_id");
                //printReport1.t
            }

            //*** Edit ***'
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DropDownList txtStatusEdit = (DropDownList)e.Row.FindControl("txtStatusEdit");
                if ((txtStatusEdit != null))
                {
                    string sql_status = "SELECT * FROM tbl_status";
                    function.getListItem(txtStatusEdit, sql_status, "status_name", "status_id");
                    txtStatusEdit.SelectedIndex = txtStatusEdit.Items.IndexOf(txtStatusEdit.Items.FindByValue((string)DataBinder.Eval(e.Row.DataItem, "status_id").ToString()));
                }
            }
        }
Exemple #19
0
        private void Settings_Loaded(object sender, RoutedEventArgs e)
        {
            List <Book> books = bookManager.EscrowBooks();

            stkStatesOfBooks.Children.Clear();

            foreach (var item in books)
            {
                Style   style   = this.FindResource("ButtonStyle") as Style;
                Student student = studentManager.Get(item.BookLocation);

                StackPanel panel = new StackPanel();
                panel.Orientation = Orientation.Horizontal;


                Button button1 = new Button();
                button1.Click  += Button1_Click;
                button1.Content = "Kitap: " + item.BookName;
                button1.Style   = style;
                button1.Width   = 250;

                panel.Children.Add(button1);


                Button button2 = new Button();
                button2.Click  += Button2_Click;
                button2.Content = "Öğrenci: " + student.StudentName;
                button2.Style   = style;
                button2.Width   = 250;

                panel.Children.Add(button2);

                Label label3 = new Label();
                label3.FontSize = 16;

                string detay = DateDifference.WhatDifference(DateTime.Now, item.DateOfCommitment).ToString();

                BrushConverter bc = new BrushConverter();

                int detayNum = Temizle(detay);



                label3.Content = " - " + DateDifference.RemoveHour(item.DateOfIssue) + " aldı - "
                                 + DateDifference.RemoveHour(item.DateOfCommitment) +
                                 " vermeli - ";

                if (detayNum == 0)
                {
                    label3.Foreground = (Brush)bc.ConvertFrom("orange");
                    label3.Content   += "bugün vermeli";
                    listBugun.Add(item);
                }
                else if (detayNum < 0)
                {
                    label3.Foreground = (Brush)bc.ConvertFrom("red");
                    label3.Content   += detay.Replace("-", null) + " süresi geçti";
                    listDolanlar.Add(item);
                }
                else if (detayNum > 1)
                {
                    label3.Foreground = (Brush)bc.ConvertFrom("green");
                    label3.Content   += detay + " var";
                    listZamaniVar.Add(item);
                }
                else if (detayNum == 1)
                {
                    label3.Foreground = (Brush)bc.ConvertFrom("steelblue");
                    label3.Content   += " yarın vermeli";
                    listYarin.Add(item);
                }


                panel.Children.Add(label3);

                stkStatesOfBooks.Children.Add(panel);
            }
        }
        protected void GridViewEmp_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //รหัสบุคคล
            Label lbempID = (Label)(e.Row.FindControl("lbempID"));

            if (lbempID != null)
            {
                lbempID.Text = (string)DataBinder.Eval(e.Row.DataItem, "emp_id");
            }


            // ชื่อ - สกุล
            Label lbempName = (Label)(e.Row.FindControl("lbempName"));

            if (lbempName != null)
            {
                lbempName.Text = (string)DataBinder.Eval(e.Row.DataItem, "profix_name") + (string)DataBinder.Eval(e.Row.DataItem, "emp_name") + "  " + (string)DataBinder.Eval(e.Row.DataItem, "emp_lname");
            }

            // สังกัดด่านฯ
            Label lbempCpoint = (Label)(e.Row.FindControl("lbempCpoint"));

            if (lbempCpoint != null)
            {
                lbempCpoint.Text = (string)DataBinder.Eval(e.Row.DataItem, "cpoint_name");
            }

            // ตำแหน่ง
            Label lbempPos = (Label)(e.Row.FindControl("lbempPos"));

            if (lbempPos != null)
            {
                lbempPos.Text = (string)DataBinder.Eval(e.Row.DataItem, "pos_name");
            }

            // หน่วย
            Label lbempAff = (Label)(e.Row.FindControl("lbempAff"));

            if (lbempAff != null)
            {
                lbempAff.Text = (string)DataBinder.Eval(e.Row.DataItem, "affi_name");
            }

            // ประเภทพนักงาน
            Label lbempType = (Label)(e.Row.FindControl("lbempType"));

            if (lbempType != null)
            {
                lbempType.Text = (string)DataBinder.Eval(e.Row.DataItem, "type_emp_name");
            }

            // อายุงาน
            Label lbempAgeWork = (Label)(e.Row.FindControl("lbempAgeWork"));

            if (lbempAgeWork != null)
            {
                string[] data      = DataBinder.Eval(e.Row.DataItem, "emp_start_working").ToString().Split('-');
                DateTime dateStart = DateTime.ParseExact(data[0] + "-" + data[1] + "-" + (int.Parse(data[2]) - 543), "dd-MM-yyyy", CultureInfo.InvariantCulture);
                if (dateStart.Date <= DateTime.Now.Date)
                {
                    DateDifference dDiff = new DateDifference(dateStart);
                    lbempAgeWork.Text = dDiff.ToString();
                }
                else
                {
                    lbempAgeWork.Text = "<span class='badge badge-pill badge-danger'>ข้อมูลวันเริ่มงานผิดพลาด</span>";
                }
            }

            // อายุงาน
            Label lbempAgeWorkNow = (Label)(e.Row.FindControl("lbempAgeWorkNow"));

            if (lbempAgeWorkNow != null)
            {
                try
                {
                    string          sql = "SELECT * FROM tbl_exp_moterway WHERE exp_moterway_emp_id = '" + (string)DataBinder.Eval(e.Row.DataItem, "emp_id") + "' AND exp_moterway_end = '00-00-0000'";
                    MySqlDataReader rs  = dbScript.selectSQL(sql);
                    if (rs.Read())
                    {
                        string[] data      = rs.GetString("exp_moterway_start").ToString().Split('-');
                        DateTime dateStart = DateTime.ParseExact(data[0] + "-" + data[1] + "-" + (int.Parse(data[2]) - 543), "dd-MM-yyyy", CultureInfo.InvariantCulture);
                        if (dateStart.Date <= DateTime.Now.Date)
                        {
                            DateDifference dDiff = new DateDifference(dateStart);
                            lbempAgeWorkNow.Text = dDiff.ToString();
                        }
                        else
                        {
                            lbempAgeWorkNow.Text = "<span class='badge badge-pill badge-danger'>ข้อมูลวันเริ่มงานตำแหน่งปัจจุบันผิดพลาด</span>";
                        }
                        rs.Close();
                    }
                    else
                    {
                        lbempAgeWorkNow.Text = "-";
                    }
                }
                catch { lbempAgeWorkNow.Text = "มีข้อผิดพลาด"; }
            }

            Button txtEmpViwe = (Button)(e.Row.FindControl("txtEmpViwe"));

            if (txtEmpViwe != null)
            {
                txtEmpViwe.CommandArgument = (string)DataBinder.Eval(e.Row.DataItem, "emp_id");
            }
            dbScript.CloseConnection();
        }
        private void fillData()
        {
            DataTable lDtHistorialMedico = new DataTable();

            ControlDePacientes.Dal.HistorialMedico lHistorialMedico = new HistorialMedico();

            lDtHistorialMedico = lHistorialMedico.HistorialMedicoGetAllForPrint(mIdHistorialMedico);

            if (lDtHistorialMedico.Rows.Count > 0)
            {
                if (lDtHistorialMedico.Rows[0]["Nombre"].ToString() != "")
                {
                    txtNombrePaciente.Text = (string)lDtHistorialMedico.Rows[0]["Nombre"];
                }
                else
                {
                    txtNombrePaciente.Text = "";
                }


                if (lDtHistorialMedico.Rows[0]["Apellido"].ToString() != "" || lDtHistorialMedico.Rows[0]["SegundoApellido"].ToString() != "")
                {
                    txtApellidoPaciente.Text = (string)lDtHistorialMedico.Rows[0]["Apellido"] + " " + (string)lDtHistorialMedico.Rows[0]["SegundoApellido"];
                }
                else
                {
                    txtApellidoPaciente.Text = "";
                }
                txtApellidoPaciente.IsEnabled = false;
                if (lDtHistorialMedico.Rows[0]["SexoName"].ToString() != "")
                {
                    txtSexo.Text = (string)lDtHistorialMedico.Rows[0]["SexoName"];
                }
                else
                {
                    txtSexo.Text = "";
                }
                txtSexo.IsEnabled = false;
                //lblEdad.Content = Convert.ToString( CalcularEdad(DateTime.Parse(Convert.ToString(lDtPaciente.Rows[0]["FechaNacimiento"]))));
                if (lDtHistorialMedico.Rows[0]["FechaNacimiento"].ToString() != "")
                {
                    DateDifference dateDifference =
                        new DateDifference(DateTime.Parse(Convert.ToString(lDtHistorialMedico.Rows[0]["FechaNacimiento"])),
                                           DateTime.Now.Date);
                    lblEdad.Content = dateDifference.ToString();
                }
                else
                {
                    lblEdad.Content = "";
                }

                if (lDtHistorialMedico.Rows[0]["NombrePadre"].ToString() != "")
                {
                    txtNombrePadre.Text = (string)lDtHistorialMedico.Rows[0]["NombrePadre"];
                }
                else
                {
                    txtNombrePadre.Text = "";
                }
                txtNombrePadre.IsEnabled = false;
                if (lDtHistorialMedico.Rows[0]["NombreMadre"].ToString() != "")
                {
                    txtNombreMadre.Text = (string)lDtHistorialMedico.Rows[0]["NombreMadre"];
                }
                else
                {
                    txtNombreMadre.Text = "";
                }
                txtNombreMadre.IsEnabled = false;
                if (lDtHistorialMedico.Rows[0]["Direccion"].ToString() != "")
                {
                    txtDireccion.Text = (string)lDtHistorialMedico.Rows[0]["Direccion"]; //unir con municipio y departamento
                }
                else
                {
                    txtDireccion.Text = "";
                }
                txtDireccion.IsEnabled = false;
                if (lDtHistorialMedico.Rows[0]["FotoPath"] == DBNull.Value || (string)lDtHistorialMedico.Rows[0]["FotoPath"] == "")
                {
                }
                else
                {
                    ControlOperation.LoadImageFromDB((byte[])lDtHistorialMedico.Rows[0]["FotoPaciente"], imgPaciente);
                }


                // lblDate.Content = (string)lDtPaciente.Rows[0]["FECHA"];

                wrpButtons.Visibility = Visibility.Visible;

                txtMotivoConsulta.Text      = lDtHistorialMedico.Rows[0]["MotivoConsulta"].ToString() != "" ? (string)lDtHistorialMedico.Rows[0]["MotivoConsulta"] : "";
                txtMotivoConsulta.IsEnabled = false;

                txtPA.Text      = lDtHistorialMedico.Rows[0]["PresionArterial"].ToString() != "" ? Convert.ToString(lDtHistorialMedico.Rows[0]["PresionArterial"]) : "";
                txtPA.IsEnabled = false;

                if (lDtHistorialMedico.Rows[0]["CodServicio"].ToString() != "")//(int) lDtPaciente.Rows[0]["CodServicio"] != 0)
                {
                    cmbServicio.SelectedValue = (int)lDtHistorialMedico.Rows[0]["CodServicio"];
                }
                else
                {
                    cmbServicio.SelectedIndex = 0;
                }
                cmbServicio.IsEnabled = false;

                txtFC.Text                = lDtHistorialMedico.Rows[0]["FrecuenciaCardiaca"].ToString() != "" ? Convert.ToString(lDtHistorialMedico.Rows[0]["FrecuenciaCardiaca"]) : "";
                txtFC.IsEnabled           = false;
                txtRX.Text                = lDtHistorialMedico.Rows[0]["RayosX"].ToString() != "" ? Convert.ToString(lDtHistorialMedico.Rows[0]["RayosX"]) : "";
                txtRX.IsEnabled           = false;
                txtFR.Text                = lDtHistorialMedico.Rows[0]["FrecuenciaRespiratora"].ToString() != "" ? Convert.ToString(lDtHistorialMedico.Rows[0]["FrecuenciaRespiratora"]) : "";
                txtFR.IsEnabled           = false;
                txtTemp.Text              = lDtHistorialMedico.Rows[0]["Temperatura"].ToString() != "" ? Convert.ToString(lDtHistorialMedico.Rows[0]["Temperatura"]) : "";
                txtTemp.IsEnabled         = false;
                txtCC.Text                = lDtHistorialMedico.Rows[0]["CC"].ToString() != "" ? Convert.ToString(lDtHistorialMedico.Rows[0]["CC"]) : "";
                txtCC.IsEnabled           = false;
                txtPeso.Text              = lDtHistorialMedico.Rows[0]["Peso"].ToString() != "" ? Convert.ToString(lDtHistorialMedico.Rows[0]["Peso"]) : "";
                txtPeso.IsEnabled         = false;
                txtTalla.Text             = lDtHistorialMedico.Rows[0]["Talla"].ToString() != "" ? Convert.ToString(lDtHistorialMedico.Rows[0]["Talla"]) : "";
                txtTalla.IsEnabled        = false;
                txtMC.Text                = lDtHistorialMedico.Rows[0]["MasaCorporal"].ToString() != "" ? Convert.ToString(lDtHistorialMedico.Rows[0]["MasaCorporal"]) : "";
                txtMC.IsEnabled           = false;
                txtTE.Text                = lDtHistorialMedico.Rows[0]["TE"].ToString() != "" ? Convert.ToString(lDtHistorialMedico.Rows[0]["TE"]) : "";
                txtTE.IsEnabled           = false;
                txtPE.Text                = lDtHistorialMedico.Rows[0]["PE"].ToString() != "" ? Convert.ToString(lDtHistorialMedico.Rows[0]["PE"]) : "";
                txtPE.IsEnabled           = false;
                txtPesoTalla.Text         = lDtHistorialMedico.Rows[0]["PesoTalla"].ToString() != "" ? Convert.ToString(lDtHistorialMedico.Rows[0]["PesoTalla"]) : "";
                txtPesoTalla.IsEnabled    = false;
                txtSaturacion.Text        = lDtHistorialMedico.Rows[0]["SaturacionO2"].ToString() != "" ? Convert.ToString(lDtHistorialMedico.Rows[0]["SaturacionO2"]) : "";
                txtSaturacion.IsEnabled   = false;
                txtExamenFisico.Text      = lDtHistorialMedico.Rows[0]["ExamenFisico"].ToString() != "" ? (string)lDtHistorialMedico.Rows[0]["ExamenFisico"] : "";
                txtExamenFisico.IsEnabled = false;
                txtAntecedentes.Text      = lDtHistorialMedico.Rows[0]["AntecedentesImportancia"].ToString() != "" ? (string)lDtHistorialMedico.Rows[0]["AntecedentesImportancia"] : "";

                txtAntecedentes.IsEnabled = false;

                if (lDtHistorialMedico.Rows[0]["EstudiosIniciales"].ToString() != "")
                {
                    txtEstudioInicial.Text = (string)lDtHistorialMedico.Rows[0]["EstudiosIniciales"];
                }
                txtEstudioInicial.IsEnabled = false;
                if (lDtHistorialMedico.Rows[0]["EstadoNutricinal"].ToString() != "")
                {
                    txtEstadoNutricional.Text = (string)lDtHistorialMedico.Rows[0]["EstadoNutricinal"];
                }
                txtEstadoNutricional.IsEnabled = false;
                if (lDtHistorialMedico.Rows[0]["ImpresionClinica"].ToString() != "")
                {
                    txtImpresion.Text = (string)lDtHistorialMedico.Rows[0]["ImpresionClinica"];
                }
                txtImpresion.IsEnabled = false;
                if (lDtHistorialMedico.Rows[0]["TratamientoConsultaExterna"].ToString() != "")
                {
                    txtTratamiento.Text = (string)lDtHistorialMedico.Rows[0]["TratamientoConsultaExterna"];
                }
                txtTratamiento.IsEnabled = false;
                if (lDtHistorialMedico.Rows[0]["Observaciones"].ToString() != "")
                {
                    txtObservaciones.Text = (string)lDtHistorialMedico.Rows[0]["Observaciones"];
                }
                txtObservaciones.IsEnabled = false;
                if (lDtHistorialMedico.Rows[0]["NotasDescargo"].ToString() == "")
                {
                    txtNotaDescargo.Text = "";
                }
                else
                {
                    txtNotaDescargo.Text = (string)lDtHistorialMedico.Rows[0]["NotasDescargo"];
                }
                txtNotaDescargo.IsEnabled = false;


                if (lDtHistorialMedico.Rows[0]["DxEgreso"].ToString() != "")
                {
                    cmbDiagnosticoFinal.SelectedValue = (int)lDtHistorialMedico.Rows[0]["DxEgreso"];
                }
                else
                {
                    cmbDiagnosticoFinal.SelectedIndex = 0;
                }
                cmbDiagnosticoFinal.IsEnabled = false;

                if (lDtHistorialMedico.Rows[0]["DxIngreso"].ToString() != "")
                {
                    cmbDiagnosticoInicial.SelectedValue = (int)lDtHistorialMedico.Rows[0]["DxIngreso"];
                }
                else
                {
                    cmbDiagnosticoInicial.SelectedIndex = 0;
                }
                cmbDiagnosticoInicial.IsEnabled = false;

                if (lDtHistorialMedico.Rows[0]["CodDestinoCaso"].ToString() != "")
                {
                    cmbDestinoCaso.SelectedValue = (int)lDtHistorialMedico.Rows[0]["CodDestinoCaso"];
                }
                else
                {
                    cmbDestinoCaso.SelectedIndex = 0;
                }
                cmbDestinoCaso.IsEnabled = false;

                txtIdPaciente.IsEnabled       = false;
                txtIdPaciente.Text            = txtIdPacienteSearch.Text;
                txtNombrePaciente.IsEnabled   = false;
                txtApellidoPaciente.IsEnabled = false;
                txtSexo.IsEnabled             = false;
                txtNombrePadre.IsEnabled      = false;
                txtNombreMadre.IsEnabled      = false;
                txtDireccion.IsEnabled        = false;

                txtNombrePaciente.IsEnabled = false;
            }
            else
            {
                ControlOperation.alertWarning("El Paciente no tiene Historial");
            }



            //DataTable lDtPaciente = new DataTable();
            //ControlDePacientes.Dal.Paciente lPaciente = new Paciente();

            //lDtPaciente = lPaciente.GetPacienteByRegistroMedico(txtIdPacienteSearch.Text);

            //if (lDtPaciente.Rows.Count > 0)
            //{
            //    txtIdPaciente.IsEnabled = false;
            //    txtIdPaciente.Text = txtIdPacienteSearch.Text;
            //    txtNombrePaciente.IsEnabled = false;
            //    txtApellidoPaciente.IsEnabled = false;
            //    txtSexo.IsEnabled = false;
            //    txtNombrePadre.IsEnabled = false;
            //    txtNombreMadre.IsEnabled = false;
            //    txtDireccion.IsEnabled = false;

            //txtNombrePaciente.IsEnabled = false;
            //if (lDtPaciente.Rows[0]["Apellido"].ToString() != "" || lDtPaciente.Rows[0]["SegundoApellido"].ToString() != "")
            //    txtApellidoPaciente.Text = (string)lDtPaciente.Rows[0]["Apellido"] + " " + (string)lDtPaciente.Rows[0]["SegundoApellido"];
            //else txtApellidoPaciente.Text = "";
            //txtApellidoPaciente.IsEnabled = false;
            //if (lDtPaciente.Rows[0]["SexoName"].ToString() != "")
            //    txtSexo.Text = (string)lDtPaciente.Rows[0]["SexoName"];
            //else txtSexo.Text = "";
            //txtSexo.IsEnabled = false;
            ////lblEdad.Content = Convert.ToString( CalcularEdad(DateTime.Parse(Convert.ToString(lDtPaciente.Rows[0]["FechaNacimiento"]))));
            //if (lDtPaciente.Rows[0]["FechaNacimiento"].ToString() != "")
            //{
            //    DateDifference dateDifference =
            //        new DateDifference(DateTime.Parse(Convert.ToString(lDtPaciente.Rows[0]["FechaNacimiento"])),
            //                           DateTime.Now.Date);
            //    lblEdad.Content = dateDifference.ToString();
            //}
            //else lblEdad.Content = "";

            //if (lDtPaciente.Rows[0]["NombrePadre"].ToString() != "")
            //    txtNombrePadre.Text = (string)lDtPaciente.Rows[0]["NombrePadre"];
            //else txtNombrePadre.Text = "";
            //txtNombrePadre.IsEnabled = false;
            //if (lDtPaciente.Rows[0]["NombreMadre"].ToString() != "")
            //    txtNombreMadre.Text = (string)lDtPaciente.Rows[0]["NombreMadre"];
            //else txtNombreMadre.Text = "";
            //txtNombreMadre.IsEnabled = false;
            //if (lDtPaciente.Rows[0]["Direccion"].ToString() != "")
            //    txtDireccion.Text = (string)lDtPaciente.Rows[0]["Direccion"]; //unir con municipio y departamento
            //else txtDireccion.Text = "";
            //txtDireccion.IsEnabled = false;
            //if (lDtPaciente.Rows[0]["FotoPath"] == DBNull.Value || (string)lDtPaciente.Rows[0]["FotoPath"] == "")
            //{ }
            //else imgPaciente.Source = new BitmapImage(new Uri((string)lDtPaciente.Rows[0]["FotoPath"]));


            //// lblDate.Content = (string)lDtPaciente.Rows[0]["FECHA"];

            //wrpButtons.Visibility = Visibility.Visible;

            // }
        }
    protected void GridAutoCad_SelectedIndexChanged(object sender, EventArgs e)
    {
        pnlspc.Visible          = false;
        dtinfo.DateSeparator    = "/";
        dtinfo.ShortDatePattern = "dd/MM/yyyy";
        con.Close(); con.Open();
        SqlDataReader dr;
        string        strSelect = GridAutoCad.SelectedRow.Cells[8].Text.ToString();

        cmd = new SqlCommand("select Batch_ID,Status,RegDate,RegNo from MCAD where SID='" + GridAutoCad.SelectedRow.Cells[2].Text.ToString() + "' and CurrentStatus='Current'", con);
        dr  = cmd.ExecuteReader();
        bool flag = false;

        if (dr.Read())
        {
            lblStBatch.Text          = dr["Batch_ID"].ToString();
            lblStatus.Text           = dr["Status"].ToString();
            lblRegistrationDAte.Text = dr["RegDate"].ToString();
            if (lblRegistrationDAte.Text != "")
            {
                lblRegistrationDAte.Text = Convert.ToDateTime(dr["RegDate"].ToString()).ToString("dd/MM/yyyy");
            }
            lblRegNo.Text = dr["RegNo"].ToString();
            flag          = true;
        }
        dr.Close();
        if (flag == false)
        {
            lblStBatch.Text          = AutoCAD.currentBatch(con).ToString();
            lblMonthDif.Text         = "0";
            lblRegNo.Text            = RegTemp();
            lblRegistrationDAte.Text = DateTime.Now.ToString("dd/MM/yyyy");
            lblStatus.Text           = "Current";
            btnSubmit.Enabled        = false;
            btnReg.Enabled           = true;
        }
        else
        {
            DateTime       dt  = Convert.ToDateTime(lblRegistrationDAte.Text, dtinfo);
            DateDifference dtd = new DateDifference(Convert.ToDateTime(txtDAte.Text, dtinfo), dt);
            decimal        dif = Convert.ToDecimal(dtd.Months + "." + dtd.Days);
            lblMonthDif.Text = dtd.Months.ToString() + " Months " + dtd.Days + " Days.";
            if (dif > 6)
            {
                lblException.Text = "Registration Period  (6th Months) Expired";
            }
            if (strSelect == "MCADLateFee")
            {
                lblFeeType.Text = "LateFee";
                btnReg.Enabled  = false; btnSubmit.Enabled = true;
            }
            else
            {
                //if (lblStatus.Text.ToString() == "LateFee")
                //{
                //check Registration Date <=6
                if (dif <= 6)
                {
                    lblFeeType.Text = "Re-Registered";
                    btnReg.Enabled  = false; btnSubmit.Enabled = true;
                }
                else
                {
                    lblFeeType.Text   = "Registered";
                    btnReg.Enabled    = true; btnSubmit.Enabled = false;
                    lblException.Text = "Registration Period (6th Months) Expired";
                }
                //}
                //else
                //{
                //    lblFeeType.Text = "Re-Registered";
                //    btnReg.Enabled = true; btnSubmit.Enabled = true;
                //}
            }
        }
        cmd = new SqlCommand("select Name,Mobile,Email,DOB from Student where SID='" + GridAutoCad.SelectedRow.Cells[2].Text.ToString() + "'", con);
        dr  = cmd.ExecuteReader();
        while (dr.Read())
        {
            txtName.Text   = dr["Name"].ToString();
            txtMobile.Text = dr["Mobile"].ToString();
            txtEmail.Text  = dr["Email"].ToString();
            txtDOB.Text    = Convert.ToDateTime(dr["DOB"].ToString()).ToString("dd/MM/yyyy");
        }
        dr.Close(); con.Close(); pnlAuto.Visible = true; con.Dispose();
    }
Exemple #23
0
        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            base.Initialize(requestContext);

            db.UserName = User.Identity.Name;

            if (string.IsNullOrWhiteSpace(Request["PrisonerId"]) == false)
            {
                PrisonerId = Convert.ToInt32(Request["PrisonerId"]);

                // Get latest admission
                var admission = db.Admissions.Include(o => o.Prisoner).Select(o => new { o.AdmissionId, o.PrisonerNumber, o.DateOfAdmission, o.PrisonerId, o.Prisoner.Name, o.Prisoner.DateOfBirth, o.Prisoner.Age, o.Prisoner.FMD1, o.Prisoner.Gender, o.Prisoner.Status }).OrderByDescending(o => o.AdmissionId).FirstOrDefault(o => o.PrisonerId == PrisonerId);

                string         name        = null;
                string         number      = null;
                string         fmd         = null;
                Gender         gender      = Gender.Male;
                string         admissionId = "";
                int            age         = 0;
                PrisonerStatus status      = PrisonerStatus.Admitted;

                DateTime?dob = null;

                if (admission != null)
                {
                    admissionId = admission.AdmissionId.ToString();
                    name        = admission.Name;
                    fmd         = admission.FMD1;
                    number      = admission.PrisonerNumber;
                    dob         = admission.DateOfBirth;
                    gender      = admission.Gender;
                    age         = admission.Age;
                    status      = admission.Status;
                }
                else
                {
                    var prisoner = db.Prisoners.Select(o => new { o.PrisonerId, o.Name, o.DateOfBirth, o.Age, o.FMD1, o.Gender, o.Status }).FirstOrDefault(o => o.PrisonerId == PrisonerId);

                    if (prisoner != null)
                    {
                        name   = prisoner.Name;
                        fmd    = prisoner.FMD1;
                        dob    = prisoner.DateOfBirth;
                        gender = prisoner.Gender;
                        age    = prisoner.Age;
                        status = prisoner.Status;
                    }
                }

                ViewBag.ComputerNumber = admissionId;
                ViewBag.PrisonerName   = name;
                ViewBag.Fingerprint    = (fmd != null ? "Captured" : "NOT Captured");
                ViewBag.PrisonerNumber = number;
                ViewBag.PrisonerGender = gender;
                ViewBag.PrisonerStatus = status;

                if (dob != null)
                {
                    DateDifference period = new DateDifference(DateTime.Now, dob.Value);
                    ViewBag.PrisonerAge = period.Years;
                }
                else
                {
                    ViewBag.PrisonerAge = age;
                }
            }

            if (string.IsNullOrWhiteSpace(Request["AdmissionId"]) == false)
            {
                AdmissionId = Convert.ToInt32(Request["AdmissionId"]);
            }

            if (string.IsNullOrWhiteSpace(Request["FIRId"]) == false)
            {
                FIRId = Convert.ToInt32(Request["FIRId"]);
            }

            if (string.IsNullOrWhiteSpace(Request["CourtHearingId"]) == false)
            {
                CourtHearingId = Convert.ToInt32(Request["CourtHearingId"]);
            }

            if (string.IsNullOrWhiteSpace(Request["MedicalTreatmentId"]) == false)
            {
                MedicalTreatmentId = Convert.ToInt32(Request["MedicalTreatmentId"]);
            }

            if (string.IsNullOrWhiteSpace(Request["Remand"]) == false)
            {
                Remand = Convert.ToInt32(Request["Remand"]);
            }
        }
Exemple #24
0
            /// <summary>
            /// Initializes a new instance of the <see cref="Storage.Task" /> class.
            /// </summary>
            /// <param name="message"> The message. </param>
            internal Task(Storage message) : base(message._rootStorage)
            {
                //GC.SuppressFinalize(message);
                _namedProperties = message._namedProperties;
                _propHeaderSize  = MapiTags.PropertiesStreamHeaderTop;

                StartDate = GetMapiPropertyDateTime(MapiTags.TaskStartDate);
                DueDate   = GetMapiPropertyDateTime(MapiTags.TaskDueDate);

                var status = GetMapiPropertyInt32(MapiTags.TaskStatus);

                if (status == null)
                {
                    Status = null;
                }
                else
                {
                    Status = (TaskStatus)status;
                }

                switch (Status)
                {
                case TaskStatus.NotStarted:
                    StatusText = LanguageConsts.TaskStatusNotStartedText;
                    break;

                case TaskStatus.InProgess:
                    StatusText = LanguageConsts.TaskStatusInProgressText;
                    break;

                case TaskStatus.Waiting:
                    StatusText = LanguageConsts.TaskStatusWaitingText;
                    break;

                case TaskStatus.Complete:
                    StatusText = LanguageConsts.TaskStatusCompleteText;
                    break;

                default:
                    StatusText = null;
                    break;
                }

                PercentageComplete = GetMapiPropertyDouble(MapiTags.PercentComplete);
                Complete           = GetMapiPropertyBool(MapiTags.TaskComplete);

                var estimatedEffort = GetMapiPropertyInt32(MapiTags.TaskEstimatedEffort);

                if (estimatedEffort == null)
                {
                    EstimatedEffort = null;
                }
                else
                {
                    EstimatedEffort = new TimeSpan(0, 0, (int)estimatedEffort);
                }

                var now = DateTime.Now;

                EstimatedEffortText = (EstimatedEffort == null
                    ? null
                    : DateDifference.Difference(now, now + ((TimeSpan)EstimatedEffort)).ToString());

                var actualEffort = GetMapiPropertyInt32(MapiTags.TaskActualEffort);

                if (actualEffort == null)
                {
                    ActualEffort = null;
                }
                else
                {
                    ActualEffort = new TimeSpan(0, 0, (int)actualEffort);
                }

                ActualEffortText = (ActualEffort == null
                    ? null
                    : DateDifference.Difference(now, now + ((TimeSpan)ActualEffort)).ToString());

                Owner              = GetMapiPropertyString(MapiTags.Owner);
                Contacts           = GetMapiPropertyStringList(MapiTags.Contacts);
                Companies          = GetMapiPropertyStringList(MapiTags.Companies);
                BillingInformation = GetMapiPropertyString(MapiTags.Billing);
                Mileage            = GetMapiPropertyString(MapiTags.Mileage);
                CompleteTime       = GetMapiPropertyDateTime(MapiTags.PR_FLAG_COMPLETE_TIME);
            }
        protected void ClaimGridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            LinkButton lbCpoint = (LinkButton)(e.Row.FindControl("lbCpoint"));

            if (lbCpoint != null)
            {
                lbCpoint.CommandName = (string)DataBinder.Eval(e.Row.DataItem, "claim_id");
            }

            LinkButton lbEquipment = (LinkButton)(e.Row.FindControl("lbEquipment"));

            if (lbEquipment != null)
            {
                lbEquipment.CommandName = (string)DataBinder.Eval(e.Row.DataItem, "claim_id");
                lbEquipment.ToolTip     = (string)DataBinder.Eval(e.Row.DataItem, "claim_equipment");
            }

            Label _lbDateStart = (Label)(e.Row.FindControl("_lbDateStart"));

            if (_lbDateStart != null)
            {
                _lbDateStart.Text = function.ConvertDateShortThai((string)DataBinder.Eval(e.Row.DataItem, "claim_start_date"));
            }

            Label lbStartDate = (Label)(e.Row.FindControl("lbStartDate"));

            if (lbStartDate != null)
            {
                lbStartDate.Text = function.ConvertDateShortThai((string)DataBinder.Eval(e.Row.DataItem, "detail_date_start"));
            }

            Label lbDay = (Label)(e.Row.FindControl("lbDay"));

            if (lbDay != null)
            {
                string[]       data      = DataBinder.Eval(e.Row.DataItem, "detail_date_start").ToString().Split('-');
                DateTime       dateStart = DateTime.ParseExact(data[0] + "-" + data[1] + "-" + (int.Parse(data[2]) - 543), "dd-MM-yyyy", CultureInfo.InvariantCulture);
                DateDifference differnce = new DateDifference(dateStart);

                if (differnce.ToString() == "")
                {
                    lbDay.CssClass = "badge badge-danger";
                    lbDay.Text     = "NEW!!";
                }
                else
                {
                    lbDay.Text = differnce.ToString();
                }
            }

            Label lbCountdown = (Label)(e.Row.FindControl("lbCountdown"));

            if (lbDay != null)
            {
                string[]       data      = DataBinder.Eval(e.Row.DataItem, "detail_date_end").ToString().Split('-');
                DateTime       dateStart = DateTime.ParseExact(data[0] + "-" + data[1] + "-" + (int.Parse(data[2]) - 543), "dd-MM-yyyy", CultureInfo.InvariantCulture);
                DateDifference differnce = new DateDifference(dateStart);
                if (dateStart < DateTime.Now.Date)
                {
                    lbCountdown.Text     = "เกินกำหนดมา " + differnce.ToString();
                    lbCountdown.CssClass = "text-danger";
                }
                else
                {
                    if (differnce.ToString() != "")
                    {
                        lbCountdown.Text     = "ครบกำหนดอีก " + differnce.ToString();
                        lbCountdown.CssClass = "text-success";
                    }
                    else
                    {
                        lbCountdown.Text     = "ครบกำหนดวันนี้ ";
                        lbCountdown.CssClass = "text-warning";
                    }
                }

                if ((string)DataBinder.Eval(e.Row.DataItem, "status_name") == "ส่งงาน/เสร็จสิ้น")
                {
                    lbCountdown.Text     = "เสร็จสิ้น";
                    lbCountdown.CssClass = "text-success";
                }
            }

            Label lbStatus = (Label)(e.Row.FindControl("lbStatus"));

            if (lbStatus != null)
            {
                lbStatus.CssClass = "badge badge-" + (string)DataBinder.Eval(e.Row.DataItem, "status_alert");
            }

            LinkButton btnChangeStatus = (LinkButton)(e.Row.FindControl("btnChangeStatus"));

            if (btnChangeStatus != null)
            {
                btnChangeStatus.CommandName = (string)DataBinder.Eval(e.Row.DataItem, "claim_id");
            }
        }
Exemple #26
0
        public IList <PrisonerViewModel> GetPrisoners(IQueryable <Admission> admissions)
        {
            var prisoners = new List <PrisonerViewModel>();

            foreach (Admission admission in admissions)
            {
                var p = new PrisonerViewModel();

                p.PrisonerId     = admission.PrisonerId;
                p.PrisonerNumber = admission.PrisonerNumber;
                p.AdmissionId    = admission.AdmissionId;
                p.Name           = admission.Prisoner.Name;
                p.Parentage      = admission.Prisoner.FatherOrHusbandName;
                p.Category       = admission.Prisoner.Category;
                p.Status         = admission.Prisoner.Status;

                p.DateOfAdmission   = admission.DateOfAdmission;
                p.DateOfRelease     = admission.DateOfRelease;
                p.HealthOnAdmission = admission.HealthOnAdmission;
                p.WeightOnAdmission = admission.WeightOnAdmission;


                p.HealthOnRelease = admission.HealthOnRelease;
                p.WeightOnRelease = admission.WeightOnRelease;
                p.District        = admission.Prisoner.PresentDistrict.Name;

                var fir = admission.FIRs.Where(o => o.AdmissionId == p.AdmissionId).OrderByDescending(o => o.FIRDate).FirstOrDefault();

                if (fir != null)
                {
                    p.FIRs = fir.FIRNumber;

                    if (fir.PoliceStation != null)
                    {
                        p.PoliceStation = fir.PoliceStation.Name;
                    }

                    var section = fir.Sections.FirstOrDefault();

                    if (section != null)
                    {
                        p.UnderSections = section.Name;
                    }
                }

                var ch = db.CourtHearings.Where(o => o.AdmissionId == admission.AdmissionId).OrderByDescending(o => o.DateOfHearing).FirstOrDefault();

                if (ch != null)
                {
                    p.TrialCourt    = ch.Court.Name;
                    p.DateOfHearing = ch.DateOfHearing;
                }

                var endDate = DateTime.Now;

                if (p.DateOfRelease != null)
                {
                    endDate = p.DateOfRelease.Value;
                }

                DateDifference period = new DateDifference(endDate, admission.DateOfAdmission);
                p.Years  = period.Years;
                p.Months = period.Months;
                p.Days   = period.Days;

                prisoners.Add(p);
            }

            return(prisoners);
        }
Exemple #27
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            textBox1.Text = DateTime.Now.ToString("dd/MM/yyyy");
            string     status = "", salary = "";
            string     joinD      = "";
            double     curPayment = 0.00;
            string     q1         = "select empName,salary,status,joinDate from employeeInfo where empID='" + comboBox1.Text + "'";
            string     q2         = "select sum(currentPayment) from empPayment where empID='" + comboBox1.Text + "'";
            SqlCommand cmd        = new SqlCommand(q1, aa);

            try
            {
                aa.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    textBox6.Text = dr.GetValue(0).ToString();
                    salary        = dr.GetValue(1).ToString();
                    textBox7.Text = dr.GetValue(1).ToString();
                    status        = dr.GetValue(2).ToString();
                    joinD         = dr.GetValue(3).ToString();
                }

                dr.Close();
                SqlCommand    cmd2     = new SqlCommand(q2, aa);
                SqlDataReader dr2      = cmd2.ExecuteReader();
                string        curPtemp = "";
                while (dr2.Read())
                {
                    curPtemp = dr2.GetValue(0).ToString();
                }

                if (curPtemp != "")
                {
                    curPayment = Convert.ToDouble(curPtemp);
                }
                else
                {
                    curPayment = 0.00;
                }
                dr2.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "errror!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                aa.Close();
            }
            //salary calculation
            string[] s = status.Split(' ');

            // MessageBox.Show(s[0] + "\t" + s[1]);

            if (s[0] == "Inactive")
            {
                label12.Text = "Inactive";
                string activeDate = joinD;

                DateTime       jdate          = Convert.ToDateTime(activeDate);
                DateTime       currentdate    = Convert.ToDateTime(s[1].ToString());
                DateDifference dateDifference = new DateDifference(jdate, currentdate);

                string DiffDate = dateDifference.ToString();
                //  MessageBox.Show(DiffDate);
                string[] sDD = DiffDate.Split('/');
                int      yy  = Convert.ToInt32(sDD[0]);
                int      mm  = Convert.ToInt32(sDD[1]);
                int      dd  = Convert.ToInt32(sDD[2]);
                //if (dd != 0)
                //{
                //    mm += 1;
                //}
                int totalMonth = (yy * 12) + mm;
                textBox8.Text = totalMonth.ToString();

                double totalSal = totalMonth * Convert.ToDouble(salary);
                double dueSal   = totalSal - curPayment;
                textBox2.Text = dueSal.ToString();
            }
            else if (s[0] == "Active")
            {
                label12.Text = "Active";
                string activeDate = s[1].ToString();

                DateTime       jdate          = Convert.ToDateTime(activeDate);
                DateTime       currentdate    = DateTime.Now;
                DateDifference dateDifference = new DateDifference(jdate, currentdate);

                string   DiffDate = dateDifference.ToString();
                string[] sDD      = DiffDate.Split('/');
                int      yy       = Convert.ToInt32(sDD[0]);
                int      mm       = Convert.ToInt32(sDD[1]);
                int      dd       = Convert.ToInt32(sDD[2]);
                //if (dd != 0)
                //{
                //    mm += 1;
                //}
                int totalMonth = (yy * 12) + mm;
                textBox8.Text = totalMonth.ToString();

                double totalSal = totalMonth * Convert.ToDouble(salary);
                double dueSal   = totalSal - curPayment;
                textBox2.Text = dueSal.ToString();
            }
            else
            {
                MessageBox.Show("Error to receive data.try again..........", "warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }