Exemplo n.º 1
0
 public ActionResult CHOT_CAPPHAT(List<int> lstIDDonthuoc, DateTime Ngay_Chot)
 {
     int v_intResult;
     ActionResult actResult;
     try
     {
         using (var scope = new TransactionScope())
         {
             using (var dbscope = new SharedDbConnectionScope())
             {
                 TLichsuChotthuoc _newItem = new TLichsuChotthuoc();
                 _newItem.NgayChot = Ngay_Chot;
                 _newItem.NguoiChot = globalVariables.UserName;
                 _newItem.IsNew = true;
                 _newItem.Save();
                 object obj = TLichsuChotthuoc.CreateQuery().GetMax("ID_CHOT");
                 TPhieuXuatthuocBenhnhanCollection vCollection = new TPhieuXuatthuocBenhnhanCollection();
                 v_intResult = new Update(TPhieuXuatthuocBenhnhan.Schema.TableName).Set(TPhieuXuatthuocBenhnhan.NgayChotColumn).EqualTo(Ngay_Chot)
                         .Set(TPhieuXuatthuocBenhnhan.IdChotColumn).EqualTo(Utility.Int32Dbnull(obj, -1))
                         .Where(TPhieuXuatthuocBenhnhan.NgayChotColumn).IsNull()
                         .And(TPhieuXuatthuocBenhnhan.IdDonthuocColumn).In(lstIDDonthuoc)
                         .Execute();
             }
             scope.Complete();
             return ActionResult.Success;
         }
     }
     catch (Exception ex)
     {
         Utility.ShowMsg("Lỗi:\n" + ex.ToString());
         return ActionResult.Error;
     }
 }
Exemplo n.º 2
0
        private void cmdMoKhoa_Click(object sender, EventArgs e)
        {
            try
            {
                if(!Utility.AcceptQuestion("Bạn có chắc chắn muốn mở khóa bệnh nhân này không ?","Xác nhận", true))
                    return;
                int record = -1;
                record =
                    new Update(TPatientExam.Schema).Set(TPatientExam.Columns.Locked).EqualTo(0).Where(
                        TPatientExam.Columns.PatientCode)
                        .IsEqualTo(txtPatientCode.Text).Execute();
                if(record > 0)
                {
                    Utility.ShowMsg("Đã cập nhật thông tin thành công");
                    patientExam.Locked = 0;
                    txtTrangthai.Text = "Đã khóa";
                }
                else
                {
                    Utility.ShowMsg("Chưa cập nhật được thông tin vào cơ sở dữ liệu");
                }
            }
            catch (Exception)
            {
                Utility.ShowMsg("Có lỗi trong quá trình cập nhật thông tin vào cơ sở dữ liệu");

            }
        }
Exemplo n.º 3
0
 public void Update_Should_Set_DBType_For_Settings() {
     var provider = ProviderFactory.GetProvider("Northwind");
     var qry = new Update<SouthWind.Order>(provider)
         .Set("RequiredDate").EqualTo(DateTime.Parse("1/12/2001"));
         
     var cmd = qry.GetCommand();
     Assert.Equal(cmd.Parameters[0].DataType, DbType.DateTime);
 }
Exemplo n.º 4
0
        public void Github_Issue211_Update_Should_Support_IsNotNull_Constraint()
        {
            var provider = ProviderFactory.GetProvider("Northwind");
            var qry = new Update<SouthWind.Order>(provider)
                .Where(o => o.EmployeeID != null)
                .Set("RequiredDate").EqualTo(new DateTime(2001, 12, 1));

            Assert.Contains("IS NOT NULL", qry.GetCommand().CommandSql);
        }
Exemplo n.º 5
0
        public void Github_Issue210_Update_Should_Support_Boolean_And_Constraints()
        {
            var provider = ProviderFactory.GetProvider("Northwind");
            var qry = new Update<SouthWind.Order>(provider)
                .Where(x=> x.EmployeeID < 100 && x.OrderID > 100)
                .Set("RequiredDate").EqualTo(new DateTime(2001, 12, 1));

            Assert.Contains("WHERE [Orders].[EmployeeID] < @0 AND [Orders].[OrderID] > @1", qry.GetCommand().CommandSql);
        }
Exemplo n.º 6
0
        public void Github_Issue210_Update_Should_Support_GreaterThan_Comparison_Constraints()
        {
            var provider = ProviderFactory.GetProvider("Northwind");
            var qry = new Update<SouthWind.Order>(provider)
                .Where(x => x.EmployeeID > 100)
                .Set("RequiredDate").EqualTo(new DateTime(2001, 12, 1));

            Assert.Contains("[Orders].[EmployeeID] > @0", qry.GetCommand().CommandSql);
        }
Exemplo n.º 7
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        var exists = Exists();
                        if (exists)
                        {

                            int record = new Update(BangGium.Schema).Set(BangGium.Columns.Price).EqualTo(nmrPrice.Value)
                                .Where(BangGium.Columns.TestTypeId).IsEqualTo(_TestTypeId).And(
                                    BangGium.Columns.TestDataId)
                                .IsEqualTo(-1).Execute();
                            if (record <= 0)
                            {
                                BangGium bangGium = new BangGium();
                                bangGium.TestTypeId = _TestTypeId;
                                bangGium.TestDataId = "-1";
                                bangGium.Price = Utility.DecimaltoDbnull(nmrPrice.Value, 0);
                                bangGium.IsNew = true;
                                bangGium.Save();
                            }
                        }
                        else
                        {
                            decimal price = Utility.DecimaltoDbnull(grdDataControl.CurrentRow.Cells["Price"].Value, 0);
                            nmrPrice.Value = price;

                            int record = new Update(BangGium.Schema).Set(BangGium.Columns.Price).EqualTo(nmrPrice.Value)
                                .Where(BangGium.Columns.TestTypeId).IsEqualTo(_TestTypeId)
                                .And(BangGium.Columns.TestDataId).IsEqualTo(_TestDataId).Execute();
                            if (record <= 0)
                            {
                                BangGium bangGium = new BangGium();
                                bangGium.TestTypeId = _TestTypeId;
                                bangGium.TestDataId = _TestDataId;
                                bangGium.Price = Utility.DecimaltoDbnull(nmrPrice.Value, 0);
                                bangGium.IsNew = true;
                                bangGium.Save();
                            }
                        }
                    }
                    Scope.Complete();
                    //Utility.ShowMsg("Lưu thông tin thành công.");
                }

            }
            catch (Exception)
            {
                Utility.ShowMsg("Có lỗi trong quá trình lưu thông tin");
                throw;
            }
        }
Exemplo n.º 8
0
        public ActionResult AddNewPatientExam(KcbDanhsachBenhnhan objPatientInfo, KcbLuotkham objLuotkham, KcbDangkyKcb objRegExam, int KieuKham)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var dbscope = new SharedDbConnectionScope())
                    {
                        UpdatePatientInfo(objPatientInfo);
                        SqlQuery sqlQueryPatientExam = new Select().From(KcbLuotkham.Schema)
                           .Where(KcbLuotkham.Columns.IdBenhnhan).IsNotEqualTo(objLuotkham.IdBenhnhan)
                           .And(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham);
                        if (sqlQueryPatientExam.GetRecordCount() > 0)//Nếu BN khác đã lấy mã này
                        {

                            objLuotkham.MaLuotkham = THU_VIEN_CHUNG.KCB_SINH_MALANKHAM();

                        }
                        objLuotkham.IsNew = true;
                        objLuotkham.Save();
                        if (objLuotkham.TrangthaiNoitru >= 1)
                        {
                            SqlQuery sqlQuery = new Select().From(KcbLuotkham.Schema).Where(
                                KcbLuotkham.Columns.MaLuotkham).IsNotEqualTo(objLuotkham.MaLuotkham)
                                .And(KcbLuotkham.Columns.SoBenhAn).IsEqualTo(objLuotkham.SoBenhAn)
                                .And(KcbLuotkham.Columns.TrangthaiNoitru).IsGreaterThanOrEqualTo(1);

                            if (sqlQuery.GetRecordCount() > 0)
                            {
                                var query = new Update(KcbLuotkham.Schema)
                                     .Set(KcbLuotkham.Columns.SoBenhAn).EqualTo(THU_VIEN_CHUNG.LaySoBenhAn())
                                     .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham).
                                     Execute();
                            }

                        }
                        if (objRegExam != null)
                        {
                            objRegExam.MaLuotkham = Utility.sDbnull(objLuotkham.MaLuotkham);
                            objRegExam.IdBenhnhan = Utility.Int32Dbnull(objLuotkham.IdBenhnhan);
                            AddRegExam(objRegExam,objLuotkham, false, KieuKham);
                        }
                        scope.Complete();
                        return ActionResult.Success;
                    }
                }
            }
            catch (Exception ex)
            {
                return ActionResult.Error;
            }
        }
    //end row commands

    /// <summary>
    /// flag quote as hidden from client vieww
    /// </summary>
    /// <param name="quoteid">Int32 unique id of quote</param>
    protected bool hide_quote(Int32 quoteid)
    {
        //save log id to price table
        int recordsaffected = 0;

        SubSonic.Update upd1 = new SubSonic.Update(DAL.Pricer.Schemas.PriceValue);
        recordsaffected = upd1.Set("client_visible").EqualTo(false)
                          .Where("quote_id").IsEqualTo(quoteid)
                          .Execute();

        if (recordsaffected > 0)
        {
            return(true);
        }
        return(false);
    }
Exemplo n.º 10
0
    //end default view
    /// <summary>
    /// update pricer with linked order id and order table with the quote id
    /// </summary>
    /// <param name="orderid">int32 orderid from grid</param>
    /// <returns></returns>
    protected bool save_to_quote(Int32 orderid, Int32 orderno, Int32 quoteid)
    {
        bool _result         = false;
        int  recordsaffected = 0;

        //save orderid to price values


        if (orderid > 0 && quoteid > 0)
        {
            //append to audit log
            UserClass _thisuser          = (UserClass)Session["user"];
            DAL.Pricer.PriceOrderLog _oq = new DAL.Pricer.PriceOrderLog();
            _oq.CompanyId = _thisuser.CompanyId;
            _oq.UserId    = _thisuser.UserId;
            _oq.QuoteId   = quoteid;
            _oq.LogDate   = DateTime.Now;
            _oq.OrderId   = orderid;
            _oq.OrderNo   = orderno;
            _oq.Save();

            //get log id
            Int32 _newid = (Int32)_oq.GetPrimaryKeyValue();

            //save log id to price table
            SubSonic.Update upd1 = new SubSonic.Update(DAL.Pricer.Schemas.PriceValue);
            recordsaffected = upd1.Set("po_log_id").EqualTo(_newid)
                              .Where("quote_id").IsEqualTo(quoteid)
                              .Execute();

            //save quote id to order table
            SubSonic.Update upd2 = new SubSonic.Update(DAL.Logistics.Schemas.OrderTable);
            recordsaffected = upd2.Set("quote_id").EqualTo(quoteid)
                              .Where("OrderID").IsEqualTo(orderid)
                              .Execute();

            if (recordsaffected > 0)
            {
                _result = true;
            }
        }
        return(_result);
    }
Exemplo n.º 11
0
 private void cmdNhapKetLuan_Click(object sender, EventArgs e)
 {
     int record=new Update(TAssignDetail.Schema)
         .Set(TAssignDetail.Columns.Summary).EqualTo(txtKetLuan.Text)
         .Set(TAssignDetail.Columns.BsThucHien).EqualTo(globalVariables.UserName)
         .Set(TAssignDetail.Columns.NgayThucHien).EqualTo(BusinessHelper.GetSysDateTime())
         .Where(TAssignDetail.Columns.AssignDetailId).IsEqualTo(AssignDetail_ID).Execute();
     if(record>0)
     {
         DataRow[] arr = P_dtDataTable.Select("AssignDetail_ID=" + AssignDetail_ID);
         if(arr.GetLength(0)>0)
         {
             arr[0][TAssignDetail.Columns.Summary] = txtKetLuan.Text;
             arr[0][TAssignDetail.Columns.NgayThucHien] = BusinessHelper.GetSysDateTime();
             arr[0][TAssignDetail.Columns.BsThucHien] = globalVariables.UserName;
         }
         P_dtDataTable.AcceptChanges();
         Utility.ShowMsg("Bạn thực hiện thành công","Thông báo");
     }
 }
Exemplo n.º 12
0
 private void cmdNhapKetLuan_Click(object sender, EventArgs e)
 {
     int record=new Update(KcbChidinhclsChitiet.Schema)
         //.Set(KcbChidinhclsChitiet.Columns.KetLuan).EqualTo(txtKetLuan.Text)
         .Set(KcbChidinhclsChitiet.Columns.NguoiThuchien).EqualTo(globalVariables.UserName)
         .Set(KcbChidinhclsChitiet.Columns.IdBacsiThuchien).EqualTo(globalVariables.gv_intIDNhanvien)
         .Set(KcbChidinhclsChitiet.Columns.NgayThuchien).EqualTo(globalVariables.SysDate)
         .Where(KcbChidinhclsChitiet.Columns.IdChitietchidinh).IsEqualTo(AssignDetail_ID).Execute();
     if(record>0)
     {
         DataRow[] arr = P_dtDataTable.Select("AssignDetail_ID=" + AssignDetail_ID);
         if(arr.GetLength(0)>0)
         {
             //arr[0][KcbChidinhclsChitiet.Columns.KetLuan] = txtKetLuan.Text;
             arr[0][KcbChidinhclsChitiet.Columns.NgayThuchien] = globalVariables.SysDate;
             arr[0][KcbChidinhclsChitiet.Columns.NguoiThuchien] = globalVariables.UserName;
             arr[0][KcbChidinhclsChitiet.Columns.IdBacsiThuchien] = globalVariables.gv_intIDNhanvien;
         }
         P_dtDataTable.AcceptChanges();
         Utility.ShowMsg("Bạn thực hiện thành công","Thông báo");
     }
 }
Exemplo n.º 13
0
        public static int UpdatePass(string Password)
        {
            bool UpdateStatus = false;
               int record = -1;
               if (globalVariables.IsAdminLogin || globalVariables.IsAdmin)
               {
               record = new Update(SysAdministrator.Schema)
              .Set(SysAdministrator.Columns.SPWD).EqualTo(objEncrypt.Mahoa(Password))
              .Where(SysAdministrator.Columns.PkSAdminID).IsEqualTo(globalVariables.UserName).Execute();
               }
               else
               {
               record = new Update(SysUser.Schema)
              .Set(SysUser.Columns.SPwd).EqualTo(objEncrypt.Mahoa(Password))
              .Where(SysUser.Columns.PkSuid).IsEqualTo(globalVariables.UserName).Execute();
               }

               if (record > 0)
               {
               UpdateStatus = true;
               }
              return record;
        }
Exemplo n.º 14
0
 /// <summary>
 /// sửa thông tin trực tiếp trên lưới
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void grdPhongBan_CellUpdated(object sender, ColumnActionEventArgs e)
 {
     int Parent_ID = 0;
     int id = Utility.Int32Dbnull(grdPhongBan.CurrentRow.Cells[DmucKhoaphong.Columns.IdKhoaphong].Value);
     int record = new Update(DmucKhoaphong.Schema)
            .Set(DmucKhoaphong.Columns.TenKhoaphong).EqualTo(grdPhongBan.CurrentRow.Cells[DmucKhoaphong.Columns.TenKhoaphong].Text)
            .Set(DmucKhoaphong.Columns.SttHthi).EqualTo(grdPhongBan.CurrentRow.Cells[DmucKhoaphong.Columns.SttHthi].Text)
            .Where(DmucKhoaphong.Columns.IdKhoaphong).IsEqualTo(Utility.Int32Dbnull(grdPhongBan.CurrentRow.Cells[DmucKhoaphong.Columns.IdKhoaphong].Text, -1))
            .Execute();
     if (record > 0)
     {
         grdPhongBan.UpdateData();
         grdPhongBan.Refresh();
         dsDepartment.AcceptChanges();
     }
     else
     {
         Utility.ShowMsg("Lỗi trong quá trình cập nhập thông tin ");
     }
     ModifyCommand();
 }
    /// <summary>
    /// this does not work either
    /// </summary>
    /// <param name="containerid"></param>
    /// <returns></returns>
    protected int mark_loaded_on_board_doesnotwork(int containerid)
    {
        //method using subsonic.codinghorror for update statements 2 and 3 as subsonic does not handle aliasing well
        //and we need to get around the multi-part identifier can't be bound problem
        int _onboard = 0;
        DateTime _currentdate = DateTime.Now;
        int _result = 0;
        //int _statusid = 12;
        SqlCommand _cmd = new SqlCommand();
        //containerid 7 or 115 or 16316 was good for testing
        using (SharedDbConnectionScope _sc = new SharedDbConnectionScope())
        {
            using (System.Transactions.TransactionScope _ts = new System.Transactions.TransactionScope())
            {
                using (SqlConnection _cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["PublishipSQLConnectionString"].ToString()))
                {
                    try
                    {
                        //disable triggers on order table or you will get this error when order_update trigger fires
                        //Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression
                        _cnn.Open();
                        _cmd.CommandType = CommandType.Text;
                        _cmd.CommandText = "ALTER TABLE [dbo].[OrderTable] DISABLE trigger ALL;";
                        _cmd.Connection = _cnn;
                        _result = _cmd.ExecuteNonQuery();
                        
                        _result = -1;
                        containerid = 115;
                        //update ordertable
                        if (_result != 0)
                        {
                            IList<int> _ids =  new Select().From(DAL.Logistics.Tables.OrderTable)
                                .InnerJoin(DAL.Logistics.ContainerSubTable.OrderIDColumn, DAL.Logistics.OrderTable.OrderIDColumn)
                                .InnerJoin(DAL.Logistics.ContainerTable.ContainerIDColumn, DAL.Logistics.ContainerSubTable.ContainerIDColumn)
                                .Where(DAL.Logistics.ContainerTable.ContainerIDColumn).IsEqualTo(containerid).ExecuteTypedList<int>();

                            if (_ids.Count > 0)
                            {
                                _result = new SubSonic.Update(DAL.Logistics.Tables.OrderTable)
                                    .Set(OrderTable.Columns.ShippedOnBoard).EqualTo(_onboard)
                                    .Where(OrderTable.Columns.OrderID).In(_ids).Execute();
                            }
                            //2. paramatised and using subsonic.codinghorror, table aliases prevent 'multi-part identifier can't be bound' tsql error
                            //UPDATE OrderTable INNER JOIN (ContainerTable INNER JOIN ContainerSubTable ON 
                            //ContainerTable.ContainerID = ContainerSubTable.ContainerID) ON (OrderTable.OrderID = ContainerSubTable.OrderID) 
                            //AND (OrderTable.OrderNumber = ContainerSubTable.OrderNumber) SET OrderTable.ShippedOnBoard = -1
                            //WHERE (((ContainerTable.ContainerID)=[Forms]![ContainerLoadedOnBoardForm].[COntainerID]));
                            //string _q2 = "UPDATE OrderTable " +
                            //                "SET OrderTable.ShippedOnBoard = @onboard " +
                            //                "FROM OrderTable as o " +
                            //                "INNER JOIN (ContainerTable AS c INNER JOIN ContainerSubTable AS s ON " +
                            //                "c.ContainerID = s.ContainerID) ON (o.OrderID = s.OrderID) " +
                            //               "AND (o.OrderNumber = s.OrderNumber)  WHERE (((c.ContainerID)= @containerid));";
                            //object[] _p2 = { _onboard, containerid };
                            //_result = new SubSonic.CodingHorror().ExecuteScalar<int>(_q2, _p2);
                        }//end if


                    }
                    catch (Exception ex)
                    {
                        _onboard = 0;
                        string _er = ex.Message.ToString();
                        this.dxlblErr.Text = _er;
                        this.dxpnlErr.ClientVisible = true;
                    }//end try/catch
                    finally
                    {
                        //re-enable triggers
                        _cmd.CommandText = "ALTER TABLE [dbo].[OrderTable] ENABLE trigger ALL;";
                        _result = _cmd.ExecuteNonQuery();
                        _cnn.Close();
                    }
                }//end using SqlConnection
            }//end using TransactionScope
        }//end using SharedDbConnectionScope
        
        return _onboard;
    }
Exemplo n.º 16
0
        /// <summary>
        /// Update một bản ghi vào bảng Danh mục dùng chung
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public void UpdateList(DmucChung obj, string strOldCode, int intSTTCu, ref string ActResult)
        {
            try
            {
                ActionResult _act = isExistedRecord4Update(obj.Loai,obj.Ma, strOldCode);
                if (_act == ActionResult.ExistedRecord || _act == ActionResult.Exception)
                {
                    ActResult = _act.ToString();
                    return;
                }
                //B1: Tim ban ghi co STT=STT moi
                DmucChungCollection v_lstDmuc = new DmucChungController().FetchByQuery(DmucChung.CreateQuery().AddWhere(DmucChung.Columns.SttHthi, Comparison.Equals, obj.SttHthi).AND(DmucChung.Columns.Loai, Comparison.Equals, obj.Loai));
                if (v_lstDmuc.Count > 0)
                {
                    new Update(DmucChung.Schema).Set(DmucChung.Columns.SttHthi).EqualTo(intSTTCu)
                        .Where(DmucChung.Columns.Ma).IsEqualTo(v_lstDmuc[0].Ma)
                        .And(DmucChung.Columns.Loai).IsEqualTo(v_lstDmuc[0].Loai).Execute();
                }
                if (Utility.Byte2Bool(obj.TrangthaiMacdinh))
                    new Update(DmucChung.Schema).Set(DmucChung.Columns.TrangthaiMacdinh).EqualTo(0)
                        .Where(DmucChung.Columns.Ma).IsNotEqualTo(obj.Ma)
                        .And(DmucChung.Columns.Loai).IsEqualTo(obj.Loai).Execute();

                int record = new Update(DmucChung.Schema)
                    .Set(DmucChung.Columns.Ma).EqualTo(obj.Ma)
                    .Set(DmucChung.Columns.Ten).EqualTo(obj.Ten)
                    .Set(DmucChung.Columns.VietTat).EqualTo(obj.VietTat)
                    .Set(DmucChung.Columns.SttHthi).EqualTo(obj.SttHthi)
                    .Set(DmucChung.Columns.MotaThem).EqualTo(obj.MotaThem)
                    .Set(DmucChung.Columns.TrangThai).EqualTo(obj.TrangThai)
                    .Set(DmucChung.Columns.TrangthaiMacdinh).EqualTo(obj.TrangthaiMacdinh)
                    .Set(DmucChung.Columns.NgaySua).EqualTo(obj.NgaySua)
                    .Set(DmucChung.Columns.NguoiSua).EqualTo(obj.NguoiSua)
                    .Where(DmucChung.Columns.Ma).IsEqualTo(strOldCode).
                    And(DmucChung.Columns.Loai).IsEqualTo(obj.Loai).Execute();
                if (record > 0)
                {
                    ActResult = ActionResult.Success.ToString();
                }
                else
                    ActResult = ActionResult.Error.ToString();
            }
            catch
            {
                ActResult = ActionResult.Exception.ToString();
            }
        }
Exemplo n.º 17
0
        private void grdDiease_CellUpdated(object sender, ColumnActionEventArgs e)
        {
            try
            {
                int record = new Update(DmucBenh.Schema)
                 .Set(DmucBenh.Columns.TenBenh).EqualTo(Utility.sDbnull(grdDiease.CurrentRow.Cells[DmucBenh.Columns.TenBenh].Value, ""))
                 .Set(DmucBenh.Columns.MaBenh).EqualTo(Utility.sDbnull(grdDiease.CurrentRow.Cells[DmucBenh.Columns.MaBenh].Value, ""))
                 .Set(DmucBenh.Columns.MotaThem).EqualTo(Utility.sDbnull(grdDiease.CurrentRow.Cells[DmucBenh.Columns.MotaThem].Value, ""))
                 .Where(DmucBenh.Columns.IdBenh).IsEqualTo(Utility.Int32Dbnull(grdDiease.CurrentRow.Cells[DmucBenh.Columns.IdBenh].Value, -1)).Execute();

                if (record > 0)
                {
                    grdDiease.UpdateData();
                    grdDiease.Refresh();
                    m_dtDiease.AcceptChanges();
                    Utility.ShowMsg("Bạn thực hiện cập nhập thông tin thành công");
                }
                else
                {
                    Utility.ShowMsg("Lỗi trong quá trình cập nhập dữ liệu");
                    return;
                }
            }
            catch (Exception exception)
            {

            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Hàm thực hiện Update thông tin 
        /// </summary>
        private void PerformActionUpdate()
        {
            int record=  new Update(DmucNoiKCBBD.Schema)
                .Set(DmucNoiKCBBD.Columns.TenKcbbd).EqualTo(Utility.sDbnull(txtDieaseName.Text, ""))
                .Set(DmucNoiKCBBD.Columns.MaKcbbd).EqualTo(txtClinicCode.Text)
                .Set(DmucNoiKCBBD.Columns.SttHthi).EqualTo(Utility.Int16Dbnull(txtIntOrder.Value, 1))
                .Set(DmucNoiKCBBD.Columns.MaDiachinh).EqualTo(Utility.sDbnull(cboSurveys.SelectedValue, ""))
                .Set(DmucNoiKCBBD.Columns.MotaThem).EqualTo(txtsDesc.Text)
               // .Set(DmucNoiKCBBD.Columns.s).EqualTo(txtsDesc.Text)
                .Where(DmucNoiKCBBD.Columns.IdKcbbd).IsEqualTo(Utility.DecimaltoDbnull(txtClinic_ID.Text, -1)).Execute();

            if(record>0)
            {
                DataRow[] dr = globalVariables.gv_dtDmucNoiKCBBD.Select(DmucNoiKCBBD.Columns.IdKcbbd+"=" + Utility.Int32Dbnull(txtClinic_ID.Text, -1));
                if (dr.GetLength(0) > 0)
                {
                    dr[0][DmucNoiKCBBD.Columns.SttHthi] = Utility.Int16Dbnull(txtIntOrder.Text, -1);
                    dr[0][DmucNoiKCBBD.Columns.MaKcbbd] = txtClinicCode.Text;
                    dr[0][DmucNoiKCBBD.Columns.TenKcbbd] = Utility.sDbnull(txtDieaseName.Text, "");
                    dr[0][DmucNoiKCBBD.Columns.MaDiachinh] = Utility.sDbnull(cboSurveys.SelectedValue, "");
                    dr[0][DmucNoiKCBBD.Columns.MotaThem] = Utility.sDbnull(txtsDesc.Text, "");
                    dr[0][DmucDiachinh.Columns.TenDiachinh] = Utility.sDbnull(cboSurveys.Text, "");

                }
                //globalVariables.gv_dtDmucNoiKCBBD.AcceptChanges();
                Utility.GotoNewRowJanus(grdList, DmucNoiKCBBD.Columns.MaKcbbd, txtClinicCode.Text);
                this.Close();
            }
            else
            {
                Utility.ShowMsg("Lỗi trong quá trình cập nhập dữ liệu");
                return;
            }
        }
        private void SaveAll()
        {
            try
            {
                Utility.SetMsg(lblMsg, "", false);
                decimal GiaDV = LayGiaDV();
                int idThuoc = -1;
                decimal GiaPhuThu = 0;
                decimal GiaBHYT = LayGiaBHYT();
                string KTH = "ALL";

                foreach (Janus.Windows.GridEX.GridEXRow gridExRow in grdQhe.GetRows())
                {
                    idThuoc = Utility.Int32Dbnull(gridExRow.Cells[QheDoituongThuoc.Columns.IdThuoc].Value, -1);
                     KTH = Utility.sDbnull(cboKhoaTH.SelectedValue, "-1") == "-1" ? "ALL" : Utility.sDbnull(cboKhoaTH.SelectedValue, "-1");
                    SqlQuery q =
                        new Select().From(QheDoituongThuoc.Schema).Where(QheDoituongThuoc.Columns.IdThuoc).
                            IsEqualTo(Utility.DecimaltoDbnull(gridExRow.Cells[QheDoituongThuoc.Columns.IdThuoc].Value, -1)).And(
                                QheDoituongThuoc.Columns.MaDoituongKcb).IsEqualTo(Utility.sDbnull(gridExRow.Cells[QheDoituongThuoc.Columns.MaDoituongKcb].Value, "-1"));
                                //.And(QheDoituongThuoc.Columns.MaKhoaThuchien).IsEqualTo(KTH);
                                //.Or(QheDoituongThuoc.Columns.MaDoituongKcb).IsEqualTo("BHYT");
                    GiaPhuThu = Utility.DecimaltoDbnull(gridExRow.Cells[QheDoituongThuoc.Columns.PhuthuTraituyen].Value, 0);
                    int v_IdLoaidoituongKcb = Utility.Int32Dbnull(gridExRow.Cells[QheDoituongThuoc.Columns.IdLoaidoituongKcb].Value, 0);

                    //Nếu có lưu đối tượng BHYT và tồn tại giá DV thì tự động tính phụ thu trái tuyến cho đối tượng BHYT đó
                    if (gridExRow.Cells[QheDoituongThuoc.Columns.IdLoaidoituongKcb].Value.ToString() == "0" && GiaDV > 0)
                    {
                        GiaBHYT = Utility.DecimaltoDbnull(gridExRow.Cells[QheDoituongThuoc.Columns.DonGia].Value, 0);
                        if (PropertyLib._QheGiaThuocProperties.TudongDieuChinhGiaPTTT)
                            GiaPhuThu = GiaDV - GiaBHYT > 0 ? GiaDV - GiaBHYT : 0;
                    }
                    //Nếu đối tượng BHYT có tồn tại thì update lại thông tin trong đó có giá phụ thu trái tuyến
                    if (q.GetRecordCount() > 0)
                    {

                        new Update(QheDoituongThuoc.Schema)
                            .Set(QheDoituongThuoc.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                            .Set(QheDoituongThuoc.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                            .Set(QheDoituongThuoc.Columns.IdLoaithuoc).EqualTo(
                                Utility.Int32Dbnull(gridExRow.Cells[QheDoituongThuoc.Columns.IdLoaithuoc].Value, -1))
                            .Set(QheDoituongThuoc.Columns.DonGia).EqualTo(
                                Utility.DecimaltoDbnull(gridExRow.Cells[QheDoituongThuoc.Columns.DonGia].Value, 0))
                            .Set(QheDoituongThuoc.Columns.PhuthuDungtuyen).EqualTo(
                                Utility.DecimaltoDbnull(gridExRow.Cells[QheDoituongThuoc.Columns.PhuthuDungtuyen].Value, 0))
                            .Set(QheDoituongThuoc.Columns.PhuthuTraituyen).EqualTo(GiaPhuThu)
                             .Set(QheDoituongThuoc.Columns.MaKhoaThuchien).EqualTo(KTH)
                            .Where(QheDoituongThuoc.Columns.IdQuanhe).IsEqualTo(
                                Utility.Int32Dbnull(gridExRow.Cells[QheDoituongThuoc.Columns.IdQuanhe].Value, "-1"))
                                .Execute();

                    }
                    else
                    {
                        DmucDoituongkcbCollection objectTypeCollection =
                            new DmucDoituongkcbController().FetchByQuery(
                                DmucDoituongkcb.CreateQuery().AddWhere(DmucDoituongkcb.Columns.MaDoituongKcb,
                                                                   Comparison.Equals,
                                                                   Utility.sDbnull(gridExRow.Cells[DmucDoituongkcb.Columns.MaDoituongKcb].Value, "-1")));

                        foreach (DmucDoituongkcb lObjectType in objectTypeCollection)
                        {
                            QheDoituongThuoc _newItems = new QheDoituongThuoc();
                            _newItems.IdDoituongKcb = lObjectType.IdDoituongKcb;
                            _newItems.IdLoaithuoc = Utility.Int16Dbnull(gridExRow.Cells[QheDoituongThuoc.Columns.IdLoaithuoc].Value, -1);
                            _newItems.IdThuoc = Utility.Int32Dbnull(gridExRow.Cells[QheDoituongThuoc.Columns.IdThuoc].Value, -1);
                            _newItems.TyleGiamgia = 0;
                            _newItems.KieuGiamgia = "%";
                            _newItems.DonGia = Utility.DecimaltoDbnull(gridExRow.Cells[QheDoituongThuoc.Columns.DonGia].Value, 0);
                            _newItems.PhuthuDungtuyen = Utility.DecimaltoDbnull(gridExRow.Cells[QheDoituongThuoc.Columns.PhuthuDungtuyen].Value, 0);
                            _newItems.PhuthuTraituyen = GiaPhuThu;
                            _newItems.IdLoaidoituongKcb = Utility.Int32Dbnull(gridExRow.Cells[QheDoituongThuoc.Columns.IdLoaidoituongKcb].Value, -1);
                            _newItems.MaDoituongKcb = lObjectType.MaDoituongKcb;

                            _newItems.NguoiTao = globalVariables.UserName;
                            _newItems.NgayTao = globalVariables.SysDate;
                            _newItems.MaKhoaThuchien = KTH;
                            _newItems.IsNew = true;
                            _newItems.Save();
                            gridExRow.BeginEdit();
                            gridExRow.Cells[QheDoituongThuoc.Columns.IdQuanhe].Value = _newItems.IdQuanhe;
                            gridExRow.EndEdit();
                        }
                    }
                    gridExRow.BeginEdit();
                    gridExRow.Cells[QheDoituongThuoc.Columns.PhuthuTraituyen].Value = GiaPhuThu;
                    gridExRow.EndEdit();
                    grdQhe.UpdateData();
                    //Nếu có chỉnh giá dịch vụ-->Tự động chỉnh giá danh mục thuốc
                    if (PropertyLib._QheGiaThuocProperties.TudongDieuChinhGiaDichVu)
                    {
                        SqlQuery sqlQuery = new Select().From(DmucDoituongkcb.Schema)
                            .Where(DmucDoituongkcb.Columns.IdLoaidoituongKcb).IsEqualTo(1)
                            .And(DmucDoituongkcb.Columns.MaDoituongKcb).IsEqualTo(Utility.sDbnull(gridExRow.Cells[QheDoituongThuoc.Columns.MaDoituongKcb].Value, "-1"));
                        DmucDoituongkcb objectType = sqlQuery.ExecuteSingle<DmucDoituongkcb>();
                        if (objectType != null)
                        {
                            new Update(DmucThuoc.Schema)
                                .Set(DmucThuoc.Columns.DonGia)
                                .EqualTo(Utility.DecimaltoDbnull(gridExRow.Cells[QheDoituongThuoc.Columns.DonGia].Value, 0))
                                .Where(DmucThuoc.Columns.IdThuoc)
                                .IsEqualTo(Utility.Int32Dbnull(gridExRow.Cells[QheDoituongThuoc.Columns.IdThuoc].Value, -1)).Execute();
                        }
                    }
                }
                new Update(DmucThuoc.Schema).Set(DmucThuoc.Columns.DonGia).EqualTo(GiaDV)
                   .Set(DmucThuoc.Columns.GiaBhyt).EqualTo(GiaBHYT)
                   .Where(DmucThuoc.Columns.IdThuoc).IsEqualTo(Utility.Int32Dbnull(grdList.CurrentRow.Cells[DmucThuoc.Columns.IdThuoc].Value, -1))
                   .Execute();
                //Cập nhật giá BHYT cho các khoa khác
                if (PropertyLib._QheGiaThuocProperties.TudongDieuChinhGiaBHYT)
                {
                    if (GiaBHYT >= 0)
                    {
                        QheDoituongThuocCollection lstItems =
                            new Select().From(QheDoituongThuoc.Schema).
                            Where(QheDoituongThuoc.Columns.IdThuoc).
                                  IsEqualTo(idThuoc)
                                  .And(QheDoituongThuoc.MaKhoaThuchienColumn).IsNotEqualTo(KTH).ExecuteAsCollection<QheDoituongThuocCollection>();
                        foreach (QheDoituongThuoc item in lstItems)
                        {
                            int v_IdLoaidoituongKcb = item.IdLoaidoituongKcb;
                            if (v_IdLoaidoituongKcb == 1)
                                GiaDV = item.DonGia;
                        }
                        GiaPhuThu = 0;
                        foreach (QheDoituongThuoc item in lstItems)
                        {
                            int v_IdLoaidoituongKcb = item.IdLoaidoituongKcb;
                            if (v_IdLoaidoituongKcb.ToString() == "0" && GiaDV > 0)//Nếu là đối tượng BHYT
                            {
                                GiaPhuThu = GiaDV - GiaBHYT > 0 ? GiaDV - GiaBHYT : 0;
                                Update _update = new Update(QheDoituongThuoc.Schema).Set(QheDoituongThuoc.DonGiaColumn).EqualTo(GiaBHYT);
                                if (PropertyLib._QheGiaThuocProperties.TudongDieuChinhGiaPTTT)
                                    _update.Set(QheDoituongThuoc.PhuthuTraituyenColumn).EqualTo(GiaPhuThu);
                                _update.Where(QheDoituongThuoc.IdLoaidoituongKcbColumn).IsEqualTo(0).And(QheDoituongThuoc.IdThuocColumn).IsEqualTo(idThuoc)
                                .And(QheDoituongThuoc.MaKhoaThuchienColumn).IsNotEqualTo(KTH)
                                .Execute();
                            }
                        }
                    }
                }
                Utility.SetMsg(lblMsg, "Bạn thực hiện cập nhập giá thành công",false);
            }
            catch (Exception exception)
            {
                Utility.SetMsg(lblMsg, "Lỗi trong quá trình cập nhập thông tin", false);
            }
        }
Exemplo n.º 20
0
 /// <summary>
 /// Update một bản ghi vào bảng Danh mục dùng chung
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public void UpdateList(DmucKieudmuc obj, string strOldCode,  ref string ActResult)
 {
     try
     {
         ActionResult _act = isExistedRecord4Update(obj.MaLoai, strOldCode);
         if (_act == ActionResult.ExistedRecord || _act == ActionResult.Exception)
         {
             ActResult = _act.ToString();
             return;
         }
         int record = new Update(DmucKieudmuc.Schema)
             .Set(DmucKieudmuc.Columns.MaLoai).EqualTo(obj.MaLoai)
             .Set(DmucKieudmuc.Columns.TenLoai).EqualTo(obj.TenLoai)
             .Set(DmucKieudmuc.Columns.MotaThem).EqualTo(obj.MotaThem)
             .Set(DmucKieudmuc.Columns.TrangThai).EqualTo(obj.TrangThai)
             .Set(DmucKieudmuc.Columns.NgaySua).EqualTo(obj.NgaySua)
             .Set(DmucKieudmuc.Columns.NguoiSua).EqualTo(obj.NguoiSua)
             .Where(DmucKieudmuc.Columns.Id).IsEqualTo(obj.Id).Execute();
         if (record > 0)
         {
             //Update trong bảng danh mục
             new Update(DmucChung.Schema).Set(DmucChung.Columns.Loai).EqualTo(obj.MaLoai)
                 .Where(DmucChung.Columns.Loai).IsEqualTo(strOldCode).Execute();
             ActResult = ActionResult.Success.ToString();
         }
         else
             ActResult = ActionResult.Error.ToString();
     }
     catch
     {
         ActResult = ActionResult.Exception.ToString();
     }
 }
Exemplo n.º 21
0
        private void tsmKichHoat_Click(object sender, EventArgs e)
        {
            try
            {
                if (Utility.AcceptQuestion("Bạn có chắc chắn muốn kích hoạt hiệu lực của bản ghi này không ?", "Xác nhận", true))
                    return;

                int record = new Update(HoadonCapphat.Schema).Set(HoadonCapphat.Columns.TrangThai).EqualTo(1)
                    .Where(HoadonCapphat.Columns.IdCapphat).IsEqualTo(
                        Utility.Int32Dbnull(grdCapPhat.GetValue(HoadonCapphat.Columns.IdCapphat)))
                    .Execute();
                if (record > 0)
                {
                    Utility.ShowMsg("Đã cập nhật thông tin thành công.");
                }
            }
            catch (Exception)
            {
                Utility.ShowMsg("Có lỗi trong quá trình update thông tin");

            }
        }
Exemplo n.º 22
0
        public ActionResult UPDATE_SOBIENLAI(HoadonLog lHoadonLog)
        {
            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        int record = -1;
                        record = new Update(HoadonLog.Schema).Set(HoadonLog.Columns.MauHoadon)
                            .EqualTo(lHoadonLog.MauHoadon).Set(HoadonLog.Columns.KiHieu).EqualTo(lHoadonLog.KiHieu)
                            .Set(HoadonLog.Columns.MaQuyen).EqualTo(lHoadonLog.MaQuyen)
                            .Set(HoadonLog.Columns.Serie).EqualTo(lHoadonLog.Serie)
                            .Where(HoadonLog.Columns.IdHdonLog).IsEqualTo(lHoadonLog.IdHdonLog)
                            .Execute();
                        if (record <= 0)
                        {
                            return ActionResult.Error;
                        }

                    }
                    Scope.Complete();
                    return ActionResult.Success;
                }

            }
            catch (Exception)
            {
                return ActionResult.Error;
            }
        }
        /// <summary>
        /// /hàm thực heien thông tin update thông tin lại
        /// </summary>
        private void PerformActionUpdate()
        {
            string MaDoituongKcb = "ALL";
            string NhomBaocao = "-1";
            DmucDoituongkcb objectType = DmucDoituongkcb.FetchByID(Utility.Int16Dbnull(cboDoituong.SelectedValue, -1));
            if (objectType != null)
            {
                MaDoituongKcb = objectType.MaDoituongKcb;
            }
            else
                MaDoituongKcb = "ALL";
            DmucKieukham objKieukham = DmucKieukham.FetchByID(Utility.Int16Dbnull(cboLoaiKham.SelectedValue, -1));
            if (objKieukham != null)
                NhomBaocao = Utility.sDbnull(objKieukham.NhomBaocao, "");
            else
                NhomBaocao = "-1";
            int record = new Update(DmucDichvukcb.Schema)
                .Set(DmucDichvukcb.Columns.IdKhoaphong).EqualTo(Utility.Int16Dbnull(cboDepartment1.SelectedValue, 1))
                .Set(DmucDichvukcb.Columns.MaDichvukcb).EqualTo(txtCode.Text.Trim())
                .Set(DmucDichvukcb.Columns.TenDichvukcb).EqualTo(txtName.Text.Trim())
                .Set(DmucDichvukcb.Columns.MotaThem).EqualTo(txtDesc.Text.Trim())
                .Set(DmucDichvukcb.Columns.SttHthi).EqualTo(Utility.Int16Dbnull(nmrSTT.Value))
                .Set(DmucDichvukcb.Columns.NhomBaocao).EqualTo(NhomBaocao)
                .Set(DmucDichvukcb.Columns.MaDoituongKcb).EqualTo(MaDoituongKcb)
                .Set(DmucDichvukcb.Columns.IdPhongkham).EqualTo(Utility.Int16Dbnull(cboRoomDept.SelectedValue, 1))
                .Set(DmucDichvukcb.Columns.IdBacsy).EqualTo(
                    Convert.ToInt16(cboBacSy.Items.Count > 0 ? Utility.Int16Dbnull(cboBacSy.SelectedValue, 1) : -1))
                .Set(DmucDichvukcb.Columns.IdKieukham).EqualTo(Utility.Int16Dbnull(cboLoaiKham.SelectedValue, 1))
                .Set(DmucDichvukcb.Columns.IdDoituongKcb).EqualTo(Utility.Int16Dbnull(cboDoituong.SelectedValue, -1))
                .Set(DmucDichvukcb.Columns.DonGia).EqualTo(Utility.DecimaltoDbnull(txtDongia.Text, 0))
                .Set(DmucDichvukcb.Columns.DongiaNgoaigio).EqualTo(Utility.DecimaltoDbnull(txtGiangoaigio.Text, 0))
                .Set(DmucDichvukcb.Columns.PhuthuNgoaigio).EqualTo(Utility.DecimaltoDbnull(txtPhuthungoaigio.Text, 0))
                .Set(DmucDichvukcb.Columns.TuTuc).EqualTo(Utility.Bool2byte(chkTutuc.Checked))
                .Set(DmucDichvukcb.Columns.PhuthuDungtuyen).EqualTo(Utility.DecimaltoDbnull(txtPTDT.Text, 0))
                .Set(DmucDichvukcb.Columns.PhuthuTraituyen).EqualTo(Utility.DecimaltoDbnull(txtPTTT.Text, 0))
                .Where(DmucDichvukcb.Columns.IdDichvukcb).IsEqualTo(Utility.DecimaltoDbnull(txtInsObject_ID.Text, -1)).
                Execute();
            if (record > 0)
            {
                DataRow[] dr =
                    m_dtDataRelation.Select(DmucDichvukcb.Columns.IdDichvukcb + "=" +
                                            Utility.Int32Dbnull(txtInsObject_ID.Text, -1));
                if (dr.GetLength(0) > 0)
                {
                    dr[0][DmucDichvukcb.Columns.IdDoituongKcb] = Utility.DecimaltoDbnull(cboDoituong.SelectedValue);
                    dr[0][DmucDichvukcb.Columns.IdKhoaphong] = Utility.Int16Dbnull(cboDepartment1.SelectedValue, -1);
                    dr[0][DmucDichvukcb.Columns.IdPhongkham] = Utility.Int16Dbnull(cboRoomDept.SelectedValue, -1);
                    dr[0][DmucDichvukcb.Columns.IdBacsy] = cboBacSy.Items.Count > 0
                                                               ? Utility.Int16Dbnull(cboBacSy.SelectedValue, -1)
                                                               : -1;
                    dr[0][DmucDichvukcb.Columns.IdKieukham] = Utility.Int16Dbnull(cboLoaiKham.SelectedValue, -1);
                    dr[0][DmucKieukham.Columns.TenKieukham] = cboLoaiKham.Text;
                    dr[0]["ten_khoa"] = cboDepartment1.SelectedIndex <= -1 ? "Tất cả các khoa KCB" : cboDepartment1.Text;
                    dr[0]["ten_phong"] = cboRoomDept.Text;
                    dr[0][DmucDichvukcb.Columns.MaDichvukcb] = txtCode.Text.Trim();
                    dr[0][DmucDichvukcb.Columns.TenDichvukcb] = txtName.Text.Trim();
                    dr[0]["ten_bacsi"] = cboBacSy.SelectedIndex > 0 ? cboBacSy.Text : "";
                    dr[0][DmucDichvukcb.Columns.MaDoituongKcb] = objectType != null ? objectType.MaDoituongKcb : "ALL";
                    dr[0][DmucDoituongkcb.Columns.TenDoituongKcb] = objectType != null
                                                                        ? cboDoituong.Text
                                                                        : "Tất cả các đối tượng";
                    dr[0][DmucDichvukcb.Columns.MotaThem] = Utility.DoTrim(txtDesc.Text);
                    dr[0][DmucDichvukcb.Columns.SttHthi] = Utility.Int16Dbnull(nmrSTT.Value, 1);

                    dr[0][DmucDichvukcb.Columns.DonGia] = Utility.DecimaltoDbnull(txtDongia.Text, 0);
                    dr[0][DmucDichvukcb.Columns.DongiaNgoaigio] = Utility.DecimaltoDbnull(txtGiangoaigio.Text, 0);
                    dr[0][DmucDichvukcb.Columns.PhuthuNgoaigio] = Utility.DecimaltoDbnull(txtPhuthungoaigio.Text, 0);
                    dr[0][DmucDichvukcb.Columns.TuTuc] = Utility.Bool2byte(chkTutuc.Checked);
                    dr[0][DmucDichvukcb.Columns.PhuthuDungtuyen] = Utility.DecimaltoDbnull(txtPTDT.Text, 0);
                    dr[0][DmucDichvukcb.Columns.PhuthuTraituyen] = Utility.DecimaltoDbnull(txtPTTT.Text, 0);
                }
                m_dtDataRelation.AcceptChanges();
                Close();
            }
            else
            {
                Utility.ShowMsg("Lỗi trong quá trình cập nhập dữ liệu");
                return;
            }
        }
Exemplo n.º 24
0
        public ActionResult HUYCHOT_CAPPHAT(DateTime Ngay_Chot)
        {
            int v_intResult;
            ActionResult actResult;
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var dbscope = new SharedDbConnectionScope())
                    {
                        TPhieuXuatthuocBenhnhanCollection vCollection = new TPhieuXuatthuocBenhnhanController().FetchByQuery(
                              TPhieuXuatthuocBenhnhan.CreateQuery()
                              .WHERE(TPhieuXuatthuocBenhnhan.NgayChotColumn.ColumnName, Comparison.Equals, Ngay_Chot));
                        //Lấy danh sách các lần chốt
                        List<int> lstIDChot = (from p in vCollection.AsEnumerable()
                                               select p.IdChot.Value).Distinct().ToList<int>();
                        //Update thông tin chốt về giá trị mặc định
                        v_intResult = new Update(TPhieuXuatthuocBenhnhan.Schema.TableName).Set(TPhieuXuatthuocBenhnhan.NgayChotColumn).EqualTo(null)
                            .Set(TPhieuXuatthuocBenhnhan.IdChotColumn).EqualTo(0)
                            .Where(TPhieuXuatthuocBenhnhan.NgayChotColumn).IsEqualTo(Ngay_Chot)
                            .Execute();
                        //Xóa lịch sử chốt
                        new Delete().From(TLichsuChotthuoc.Schema).Where(TLichsuChotthuoc.IdChotColumn).In(lstIDChot).Execute();

                    }
                    scope.Complete();
                    return ActionResult.Success;
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg("Lỗi:\n" + ex.ToString());
                return ActionResult.Error;
            }
        }
Exemplo n.º 25
0
        private int UpdatePaymentStatus(KcbThanhtoan objThanhtoan, KcbThanhtoanChitiet objChitietThanhtoan)
        {
            int reval = -1;
            using (var scope = new TransactionScope())
            {
                switch (objChitietThanhtoan.IdLoaithanhtoan)
                {
                    case 1://Phí KCB
                        reval=new Update(KcbDangkyKcb.Schema)
                            .Set(KcbDangkyKcb.Columns.IdThanhtoan).EqualTo(objThanhtoan.IdThanhtoan)
                            .Set(KcbDangkyKcb.Columns.TrangthaiThanhtoan).EqualTo(1)

                             .Set(KcbDangkyKcb.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                            .Set(KcbDangkyKcb.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                            .Set(KcbDangkyKcb.Columns.NgayThanhtoan).EqualTo(objThanhtoan.NgayThanhtoan)
                            .Set(KcbDangkyKcb.Columns.NguonThanhtoan).EqualTo(objThanhtoan.KieuThanhtoan)
                              .Set(KcbChidinhclsChitiet.Columns.TienChietkhau).EqualTo(objChitietThanhtoan.TienChietkhau)
                            .Set(KcbChidinhclsChitiet.Columns.TileChietkhau).EqualTo(objChitietThanhtoan.TileChietkhau)
                            .Set(KcbChidinhclsChitiet.Columns.KieuChietkhau).EqualTo(objChitietThanhtoan.KieuChietkhau)
                            .Where(KcbDangkyKcb.Columns.IdKham).IsEqualTo(objChitietThanhtoan.IdPhieu).Execute();

                        //new Update(NoitruPhanbuonggiuong.Schema)
                        //    .Set(NoitruPhanbuonggiuong.Columns.IdThanhtoan).EqualTo(objThanhtoan.IdThanhtoan)
                        //    .Set(NoitruPhanbuonggiuong.Columns.TrangthaiThanhtoan).EqualTo(1)
                        //     .Set(NoitruPhanbuonggiuong.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                        //    .Set(NoitruPhanbuonggiuong.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                        //    .Set(NoitruPhanbuonggiuong.Columns.NgayThanhtoan).EqualTo(objThanhtoan.NgayThanhtoan)
                        //     .Set(NoitruPhanbuonggiuong.Columns.NguonThanhtoan).EqualTo(objThanhtoan.KieuThanhtoan)
                        //    .Where(NoitruPhanbuonggiuong.Columns.IdKham).IsEqualTo(objChitietThanhtoan.IdPhieu)
                        //    .And(NoitruPhanbuonggiuong.Columns.NoiTru).IsEqualTo(0).Execute();
                        break;
                    case 10://Sổ khám
                        reval=new Update(KcbDangkySokham.Schema)
                           .Set(KcbDangkySokham.Columns.IdThanhtoan).EqualTo(objThanhtoan.IdThanhtoan)
                           .Set(KcbDangkySokham.Columns.TrangthaiThanhtoan).EqualTo(1)
                            .Set(KcbDangkySokham.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                           .Set(KcbDangkySokham.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                           .Set(KcbDangkySokham.Columns.NgayThanhtoan).EqualTo(objThanhtoan.NgayThanhtoan)
                           .Set(KcbDangkySokham.Columns.NguonThanhtoan).EqualTo(objThanhtoan.KieuThanhtoan)
                           .Where(KcbDangkySokham.Columns.IdSokcb).IsEqualTo(objChitietThanhtoan.IdPhieu).Execute();
                        break;
                    case 8://Gói dịch vụ
                    case 11://Công tiêm chủng
                    case 9://Chi phí thêm
                    case 2://Phí CLS
                        reval = new Update(KcbChidinhclsChitiet.Schema)
                            .Set(KcbChidinhclsChitiet.Columns.IdThanhtoan).EqualTo(objThanhtoan.IdThanhtoan)
                            .Set(KcbChidinhclsChitiet.Columns.TrangthaiThanhtoan).EqualTo(1)
                             .Set(KcbChidinhclsChitiet.Columns.TienChietkhau).EqualTo(objChitietThanhtoan.TienChietkhau)
                            .Set(KcbChidinhclsChitiet.Columns.TileChietkhau).EqualTo(objChitietThanhtoan.TileChietkhau)
                            .Set(KcbChidinhclsChitiet.Columns.KieuChietkhau).EqualTo(objChitietThanhtoan.KieuChietkhau)
                             .Set(KcbChidinhclsChitiet.Columns.NguonThanhtoan).EqualTo(objThanhtoan.KieuThanhtoan)
                            .Set(KcbChidinhclsChitiet.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                            .Set(KcbChidinhclsChitiet.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                            .Set(KcbChidinhclsChitiet.Columns.NgayThanhtoan).EqualTo(objThanhtoan.NgayThanhtoan)
                            .Where(KcbChidinhclsChitiet.Columns.IdChitietchidinh).IsEqualTo(objChitietThanhtoan.IdPhieuChitiet).Execute();
                        //09/09/2015-->Tạm thời bỏ do ko có ý nghĩa
                        //new Update(KcbChidinhcl.Schema)
                        //.Set(KcbChidinhcl.Columns.TrangthaiThanhtoan).EqualTo(1)
                        //.Set(KcbChidinhcl.Columns.NgayThanhtoan).EqualTo(objThanhtoan.NgayThanhtoan)
                        //.Where(KcbChidinhcl.Columns.IdChidinh).IsEqualTo(objChitietThanhtoan.IdPhieu).Execute();
                        break;
                    case 3://Đơn thuốc ngoại trú,nội trú
                    case 5://Vật tư tiêu hao
                        reval = new Update(KcbDonthuocChitiet.Schema)
                            .Set(KcbDonthuocChitiet.Columns.IdThanhtoan).EqualTo(objThanhtoan.IdThanhtoan)
                            .Set(KcbDonthuocChitiet.Columns.TrangthaiThanhtoan).EqualTo(1)
                            .Set(KcbDonthuocChitiet.Columns.NgayThanhtoan).EqualTo(objThanhtoan.NgayThanhtoan)
                             .Set(KcbDonthuocChitiet.Columns.TienChietkhau).EqualTo(objChitietThanhtoan.TienChietkhau)
                            .Set(KcbDonthuocChitiet.Columns.TileChietkhau).EqualTo(objChitietThanhtoan.TileChietkhau)
                            .Set(KcbDonthuocChitiet.Columns.KieuChietkhau).EqualTo(objChitietThanhtoan.KieuChietkhau)
                             .Set(KcbDonthuocChitiet.Columns.NguonThanhtoan).EqualTo(objThanhtoan.KieuThanhtoan)
                             .Set(KcbDonthuocChitiet.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                            .Set(KcbDonthuocChitiet.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                            .Where(KcbDonthuocChitiet.Columns.IdChitietdonthuoc).IsEqualTo(objChitietThanhtoan.IdPhieuChitiet).Execute();
                        //09/09/2015-->Tạm thời bỏ do ko có ý nghĩa
                        //new Update(KcbDonthuoc.Schema)
                        //   .Set(KcbDonthuoc.Columns.TrangthaiThanhtoan).EqualTo(1)
                        //   .Set(KcbDonthuoc.Columns.NgayThanhtoan).EqualTo(objThanhtoan.NgayThanhtoan)
                        //   .Where(KcbDonthuoc.Columns.IdDonthuoc).IsEqualTo(objChitietThanhtoan.IdPhieu).Execute();
                        break;

                    case 4://Giường bệnh
                        reval = new Update(NoitruPhanbuonggiuong.Schema)
                          .Set(NoitruPhanbuonggiuong.Columns.IdThanhtoan).EqualTo(objThanhtoan.IdThanhtoan)
                          .Set(NoitruPhanbuonggiuong.Columns.TrangthaiThanhtoan).EqualTo(1)
                          .Set(NoitruPhanbuonggiuong.Columns.NgayThanhtoan).EqualTo(objThanhtoan.NgayThanhtoan)
                           .Set(NoitruPhanbuonggiuong.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                          .Set(NoitruPhanbuonggiuong.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                           .Set(NoitruPhanbuonggiuong.Columns.NguonThanhtoan).EqualTo(objThanhtoan.KieuThanhtoan)
                          .Where(NoitruPhanbuonggiuong.Columns.Id).IsEqualTo(objChitietThanhtoan.IdPhieu).Execute();
                        break;
                    case 0://Phí dịch vụ kèm theo
                        reval = new Update(KcbDangkyKcb.Schema)
                          .Set(KcbDangkyKcb.Columns.IdThanhtoan).EqualTo(objThanhtoan.IdThanhtoan)
                          .Set(KcbDangkyKcb.Columns.TrangthaiThanhtoan).EqualTo(1)
                          .Set(KcbDangkyKcb.Columns.NgayThanhtoan).EqualTo(objThanhtoan.NgayThanhtoan)
                            .Set(KcbDangkyKcb.Columns.TienChietkhau).EqualTo(objChitietThanhtoan.TienChietkhau)
                            .Set(KcbDangkyKcb.Columns.TileChietkhau).EqualTo(objChitietThanhtoan.TileChietkhau)
                            .Set(KcbDangkyKcb.Columns.KieuChietkhau).EqualTo(objChitietThanhtoan.KieuChietkhau)
                             .Set(KcbDangkyKcb.Columns.NguonThanhtoan).EqualTo(objThanhtoan.KieuThanhtoan)
                              .Set(KcbDangkyKcb.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                            .Set(KcbDangkyKcb.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                          .Where(KcbDangkyKcb.Columns.IdKham).IsEqualTo(objChitietThanhtoan.IdPhieu)
                          .And(KcbDangkyKcb.Columns.LaPhidichvukemtheo).IsEqualTo(1)
                          .Execute();
                        break;
                }
                scope.Complete();
            }
            return reval;
        }
Exemplo n.º 26
0
 private void cmdKETTHUC_Click(object sender, EventArgs e)
 {
     try
     {
         if (Utility.AcceptQuestion("Bạn có chắn chắn muốn kết thúc lần khám của bệnh nhân không", "Xác nhận",
                                    true))
         {
             int record = -1;
             record = new Update(KcbLuotkham.Schema).Set(KcbLuotkham.Columns.Locked).EqualTo(1)
                 .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(txtPatient_Code.Text).Execute();
             if (record > 0)
             {
                 DataRow[] arrDr = m_dtPatients.Select( "id_kham=" + txtIdPhieudieutri.Text);
                 if (arrDr.Length > 0)
                     arrDr[0]["Locked"] = 1;
                 Utility.ShowMsg("Đã cập nhật thông tin thành công");
                 tabDiagInfo.Enabled = false;
                 cmdInphieudieutri.Visible = true;
                 // cmdBenhAnNgoaiTru.Visible = true;
             }
             else
             {
                 Utility.ShowMsg("Chưa lưu được thông tin vào cơ sở dữ liệu");
             }
             ModifyCommmands();
         }
     }
     catch (Exception)
     {
         Utility.ShowMsg("Có lỗi trong quá trình lưu thông tin");
     }
 }
Exemplo n.º 27
0
 /// <summary>
 /// Builds the update SQL.
 /// </summary>
 /// <returns></returns>
 protected void UpdateRecord(string primaryKeyValue)
 {
     Update qryUpdate = new Update(TableSchema);
     foreach(TableSchema.TableColumn col in TableSchema.Columns)
     {
         if(col.DataType != DbType.Binary && Utility.IsWritableColumn(col))
         {
             Control ctrl = FindControl(col.IsPrimaryKey ? PK_ID + col.ColumnName : col.ColumnName);
             if(ctrl != null)
             {
                 object oVal = Utility.GetDefaultControlValue(col, ctrl, false, true);
                 oVal = TransformBooleanAndDateValues(oVal, col.DataType);
                 qryUpdate.Set(col).EqualTo(oVal);
             }
         }
     }
     qryUpdate.Where(TableSchema.PrimaryKey).IsEqualTo(primaryKeyValue);
     qryUpdate.Execute();
 }
Exemplo n.º 28
0
        /// <summary>
        /// Sửa thông tin trực tiếp trên lưới
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void grdStaffList_CellUpdated(object sender, ColumnActionEventArgs e)
        {
            try
            {
                grdStaffList.UpdateData();
                grdStaffList.Refresh();
                m_dtStaffList.AcceptChanges();
                int record = new Update(DmucNhanvien.Schema)
                 .Set(DmucNhanvien.Columns.TenNhanvien).EqualTo(Utility.sDbnull(grdStaffList.CurrentRow.Cells[DmucNhanvien.Columns.TenNhanvien].Value, ""))
                 .Set(DmucNhanvien.Columns.MaNhanvien).EqualTo(Utility.sDbnull(grdStaffList.CurrentRow.Cells[DmucNhanvien.Columns.MaNhanvien].Value, ""))
                 .Set(DmucNhanvien.Columns.MotaThem).EqualTo(Utility.sDbnull(grdStaffList.CurrentRow.Cells[DmucNhanvien.Columns.MotaThem].Value, ""))
                 .Set(DmucNhanvien.Columns.TrangThai).EqualTo(Utility.Int16Dbnull(grdStaffList.CurrentRow.Cells[DmucNhanvien.Columns.TrangThai].Value))
                 .Where(DmucNhanvien.Columns.IdNhanvien).IsEqualTo(Utility.Int32Dbnull(grdStaffList.CurrentRow.Cells[DmucNhanvien.Columns.IdNhanvien].Value, -1)).Execute();

                if (record > 0)
                {
                    grdStaffList.UpdateData();
                    grdStaffList.Refresh();
                    m_dtStaffList.AcceptChanges();
                    //Utility.ShowMsg("Bạn thực hiện cập nhập thông tin thành công");
                }
                else
                {
                    Utility.ShowMsg("Lỗi trong quá trình cập nhập dữ liệu");
                    return;
                }
            }
            catch (Exception exception)
            {

            }
        }
Exemplo n.º 29
0
        public void Github_Issue246_Update_Should_Support_Set_To_Null()
        {
            var provider = ProviderFactory.GetProvider("Northwind");
            var qry = new Update<SouthWind.Category>(provider)
                .Where(x => x.Picture == null)
                .Set(x => x.Description == null);

            Assert.Contains("SET [Categories].[Description]=@up_Description", qry.GetCommand().CommandSql);
            Assert.Contains("WHERE [Categories].[Picture] IS NULL", qry.GetCommand().CommandSql);
        }
Exemplo n.º 30
0
        public ActionResult LINH_THUOC(int Idcapphat, List<int> lstIDDonthuoc, DateTime Ngay_linh)
        {
            int v_intResult;
            ActionResult actResult;
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var dbscope = new SharedDbConnectionScope())
                    {
                        v_intResult = new Update(TPhieuCapphatChitiet.Schema.TableName)
                                .Set(TPhieuCapphatChitiet.DaLinhColumn).EqualTo(1)
                                .Set(TPhieuCapphatChitiet.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                                .Set(TPhieuCapphatChitiet.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                                .Where(TPhieuCapphatChitiet.Columns.IdCapphat).IsEqualTo(Idcapphat)
                                .And(TPhieuCapphatChitiet.IdDonthuocColumn).In(lstIDDonthuoc)
                                .And(TPhieuCapphatChitiet.DaLinhColumn).IsEqualTo(0)
                                .Execute();

                    }
                    scope.Complete();
                    return ActionResult.Success;
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg("Lỗi:\n" + ex.ToString());
                return ActionResult.Error;
            }
        }
Exemplo n.º 31
0
 private void cmdCapnhatngayinphoiBHYT_Click(object sender, EventArgs e)
 {
     try
     {
         Utility.EnableButton(cmdCapnhatngayinphoiBHYT, false);
         int record = -1;
         record =
             new Update(KcbPhieuDct.Schema).Set(KcbPhieuDct.Columns.NgayTao).EqualTo(dtNgayInPhoi.Value)
                 .Where(KcbPhieuDct.Columns.MaLuotkham).IsEqualTo(txtPatient_Code.Text)
                 .And(KcbPhieuDct.Columns.IdBenhnhan).IsEqualTo(Utility.Int32Dbnull(txtPatient_ID.Text))
                 .And(KcbPhieuDct.Columns.LoaiThanhtoan).IsEqualTo(Utility.Int32Dbnull(KieuThanhToan.NgoaiTru))
                 .Execute();
         if (record > 0)
         {
             Utility.ShowMsg("Đã cập nhật thông tin thành công.");
         }
         else
         {
             Utility.ShowMsg("Cập nhật thông tin không thành công.");
         }
     }
     catch (Exception ex)
     {
         Utility.ShowMsg("Có lỗi trong quá trình chỉnh sửa dữ liệu ngày in phiếu Đồng Chi Trả \n" + ex);
     }
     finally
     {
         Utility.EnableButton(cmdCapnhatngayinphoiBHYT, true);
     }
 }
Exemplo n.º 32
0
 public ActionResult CHOT_CAPPHAT_NOITRU(int IdCapphat, DateTime Ngay_Chot)
 {
     int v_intResult;
     ActionResult actResult;
     try
     {
         using (var scope = new TransactionScope())
         {
             using (var dbscope = new SharedDbConnectionScope())
             {
                 TLichsuChotthuoc _newItem = new TLichsuChotthuoc();
                 _newItem.NgayChot = Ngay_Chot;
                 _newItem.NguoiChot = globalVariables.UserName;
                 _newItem.Noitru = 1;
                 _newItem.IsNew = true;
                 _newItem.Save();
                 object obj = TLichsuChotthuoc.CreateQuery().GetMax("ID_CHOT");
                 v_intResult = new Update(TPhieuCapphatNoitru.Schema.TableName)
                        .Set(TPhieuCapphatNoitru.NgayChotColumn).EqualTo(Ngay_Chot)
                        .Set(TPhieuCapphatNoitru.NguoiChotColumn).EqualTo(globalVariables.UserName)
                         .Set(TPhieuCapphatNoitru.IdChotColumn).EqualTo(Utility.Int32Dbnull(obj, -1))
                         .Set(TPhieuCapphatNoitru.NgayHuychotColumn).EqualTo(null)
                          .Set(TPhieuCapphatNoitru.NguoiHuychotColumn).EqualTo(string.Empty)
                          .Set(TPhieuCapphatNoitru.LydoHuychotColumn).EqualTo(string.Empty)
                         .Where(TPhieuCapphatNoitru.NgayChotColumn).IsNull()
                         .And(TPhieuCapphatNoitru.Columns.IdCapphat).IsEqualTo(IdCapphat)
                         .Execute();
             }
             scope.Complete();
             return ActionResult.Success;
         }
     }
     catch (Exception ex)
     {
         Utility.ShowMsg("Lỗi:\n" + ex.ToString());
         return ActionResult.Error;
     }
 }