Exemplo n.º 1
0
        /// <summary>
        /// hàm thực hiện việc xác nhận thông tin
        /// </summary>
        /// <param name="objPhieuNhap"></param>
        /// <returns></returns>
        public ActionResult HuyXacNhanPhieuTraLaiKho(TPhieuNhapxuatthuoc objPhieuNhap)
        {
            HisDuocProperties objHisDuocProperties = PropertyLib._HisDuocProperties;
            string            errorMessage         = "";

            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        SqlQuery sqlQuery = new Select().From(TPhieuNhapxuatthuocChitiet.Schema)
                                            .Where(TPhieuNhapxuatthuocChitiet.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu);
                        TPhieuNhapxuatthuocChitietCollection objPhieuNhapCtCollection =
                            sqlQuery.ExecuteAsCollection <TPhieuNhapxuatthuocChitietCollection>();

                        foreach (TPhieuNhapxuatthuocChitiet objPhieuNhapCt in objPhieuNhapCtCollection)
                        {
                            //Kiểm tra ở kho nhập xem thuốc đã sử dụng chưa
                            ActionResult _Kiemtrathuochuyxacnhan = Kiemtrathuochuyxacnhan(objPhieuNhap, objPhieuNhapCt);
                            if (_Kiemtrathuochuyxacnhan != ActionResult.Success)
                            {
                                return(_Kiemtrathuochuyxacnhan);
                            }
                            int             id_thuockho = -1;
                            StoredProcedure sp          = SPs.ThuocNhapkhoOutput(objPhieuNhapCt.NgayHethan, objPhieuNhapCt.GiaNhap, objPhieuNhapCt.GiaBan,
                                                                                 objPhieuNhapCt.SoLuong, Utility.DecimaltoDbnull(objPhieuNhapCt.Vat),
                                                                                 objPhieuNhapCt.IdThuoc, objPhieuNhap.IdKhonhap, objPhieuNhapCt.MaNhacungcap,
                                                                                 objPhieuNhapCt.SoLo, objPhieuNhapCt.SoDky, objPhieuNhapCt.SoQdinhthau, -1, id_thuockho,
                                                                                 objPhieuNhap.NgayXacnhan, objPhieuNhapCt.GiaBhyt, objPhieuNhapCt.GiaPhuthuDungtuyen, objPhieuNhapCt.GiaPhuthuTraituyen, objPhieuNhapCt.KieuThuocvattu);
                            sp.Execute();
                            sp = SPs.ThuocXuatkho(objPhieuNhap.IdKhoxuat, objPhieuNhapCt.IdThuoc,
                                                  objPhieuNhapCt.NgayHethan, objPhieuNhapCt.GiaNhap, objPhieuNhapCt.GiaBan,
                                                  Utility.DecimaltoDbnull(objPhieuNhapCt.Vat),
                                                  Utility.Int32Dbnull(objPhieuNhapCt.SoLuong), objPhieuNhapCt.IdThuockho, objPhieuNhapCt.MaNhacungcap, objPhieuNhapCt.SoLo, objHisDuocProperties.XoaDulieuKhiThuocDaHet ? 1 : 0, errorMessage);

                            sp.Execute();
                            errorMessage = Utility.sDbnull(sp.OutputValues[0]);
                        }
                        //Xóa toàn bộ chi tiết trong TBiendongThuoc
                        new Delete().From(TBiendongThuoc.Schema)
                        .Where(TBiendongThuoc.IdPhieuColumn).IsEqualTo(objPhieuNhap.IdPhieu).Execute();
                        new Update(TPhieuNhapxuatthuoc.Schema)
                        .Set(TPhieuNhapxuatthuoc.Columns.IdNhanvien).EqualTo(null)
                        .Set(TPhieuNhapxuatthuoc.Columns.NguoiXacnhan).EqualTo(null)
                        .Set(TPhieuNhapxuatthuoc.Columns.NgayXacnhan).EqualTo(null)
                        .Set(TPhieuNhapxuatthuoc.Columns.TrangThai).EqualTo(0)
                        .Where(TPhieuNhapxuatthuoc.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu).Execute();
                    }
                    Scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi ban ra tu sp :{0}", errorMessage);
                log.Error("Loi trong qua trinh xac nhan don thuoc :{0}", exception);
                return(ActionResult.Error);
            }
        }
Exemplo n.º 2
0
        public long NewAdd <T>(T item) where T : class, new()
        {
            if (_options.Contains(SimpleRepositoryOptions.RunMigrations))
            {
                Migrate <T>();
            }
            var tbl     = _provider.FindOrCreateTable <T>();
            var cmd     = new StoredProcedure(tbl.Name.ToUpper() + "_PROC_INS", _provider);
            var hashed  = item.ToDictionary();
            int pkIndex = 0;

            for (int i = 0; i < tbl.Columns.Count; i++)
            {
                var col = tbl.Columns[i];
                if (col.AutoIncrement)
                {
                    cmd.Command.AddOutputParameter("P_" + col.Name.ToUpper(), System.Data.DbType.Int64);
                    pkIndex = i;
                }

                else
                {
                    cmd.Command.AddParameter("P_" + col.Name.ToUpper(), hashed[col.Name], col.DataType);
                }
            }

            cmd.Execute();

            long?returnId = cmd.Command.Parameters[pkIndex].ParameterValue as long?;

            return(returnId.GetValueOrDefault());
        }
        private List <EmailIndicator> GetEmailIndicatorList(EmailStateRequest filters)
        {
            var             response        = new List <EmailIndicator>();
            var             sessionId       = Guid.NewGuid();
            StoredProcedure storedProcedure = CreateStoredProcedure(filters, sessionId);
            Select          select          = CreateSessionSelect(sessionId);
            Delete          delete          = CreateSessionDelete(sessionId);

            using (DBExecutor dbExecutor = UserConnectionSafe.EnsureDBConnection()) {
                storedProcedure.Execute(dbExecutor);
                using (var reader = select.ExecuteReader(dbExecutor)) {
                    while (reader.Read())
                    {
                        var emailStateItem = new EmailIndicator();
                        emailStateItem.Caption = reader.GetColumnValue <string>("Caption");
                        object benchmarkValue = reader["Benchmark"];
                        if (benchmarkValue != DBNull.Value)
                        {
                            emailStateItem.Benchmark = UserConnectionSafe.DBTypeConverter.DBValueToInt(benchmarkValue);
                        }
                        object actualCountValue = reader["ActualCount"];
                        if (actualCountValue != DBNull.Value)
                        {
                            emailStateItem.ActualValue = UserConnectionSafe.DBTypeConverter.DBValueToInt(actualCountValue);
                        }
                        emailStateItem.State = reader.GetColumnValue <string>("State");
                        response.Add(emailStateItem);
                    }
                }
                delete.Execute(dbExecutor);
            }
            return(response);
        }
Exemplo n.º 4
0
        public void TestTransaction()
        {
            using (DbConnection connection = GetConnection())
            {
                connection.Open();

                DbTransaction transaction = connection.BeginTransaction();

                const string newName = "changed";

                StoredProcedure changeName = new StoredProcedure("ChangeName");
                changeName.Command.AddParameter("@Id", 2, DbType.Int32, 4);
                changeName.Command.AddParameter("@NewName", newName, DbType.String, 50);
                changeName.Execute(transaction);

                StoredProcedure getName = new StoredProcedure("GetName");
                getName.Command.AddParameter("@Id", 2, DbType.Int32, 4);
                Assert.AreEqual(newName, getName.ExecuteScalar(transaction), "The name has not been changed");

                transaction.Rollback();

                Assert.AreEqual("name2", getName.ExecuteScalar(), "The name has not been reverted");

                connection.Close();
            }
        }
Exemplo n.º 5
0
        protected virtual void ExecuteStoreProcedureWithParameters(string procedureName, Dictionary <string, object> parameters)
        {
            var storedProcedure = new StoredProcedure(_userConnection, procedureName);

            parameters.ForEach(p => storedProcedure.WithParameter(p.Key, p.Value));
            storedProcedure.Execute();
        }
Exemplo n.º 6
0
        protected void CTYS_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            DataObjectCommunity community = (DataObjectCommunity)e.Item.DataItem;

            Literal literal = (Literal)e.Item.FindControl("CTYTITLE");

            if (community.ObjectType == Helper.GetObjectTypeNumericID("ProfileCommunity"))
            {
                literal.Text = GuiLanguage.GetGuiLanguage("ProfileData").GetString("MyProfile");
            }
            else
            {
                literal.Text = community.Title;
            }
            StoredProcedure sp = SPs.HispDataObjectFindInCommunity(dataObject.ObjectID, community.ObjectID.Value, null);

            sp.Execute();
            bool ObjectFound = Convert.ToBoolean(sp.OutputValues[0]);

            literal = (Literal)e.Item.FindControl("CTYSEL");
            if (!ObjectFound)
            {
                literal.Text = "<input type=\"checkbox\" name=\"CTYSEL\" value=\"" + community.ObjectID.Value.ToString() + "\"/>";
            }
            else
            {
                literal.Text = "<input type=\"checkbox\" name=\"CTYSEL\" checked='true' disabled='true' value=\"\" />";
            }
        }
Exemplo n.º 7
0
        private void ClearUnusedReference()
        {
            var storedProcedure = new StoredProcedure(UserConnection, "tsp_RemoveUnusedReferences") as StoredProcedure;

            storedProcedure.PackageName = "tspkg_Translation";
            storedProcedure.Execute();
        }
Exemplo n.º 8
0
        public List <ReportModel> Get(ReportSearchInfo param)
        {
            var sp          = " PRC_GetReport   @Report= '" + param.Report + "',@ReportType='" + param.ReportType + "',@FromDate='" + param.FromDate + "',@ToDate='" + param.ToDate + "', @UserName='******', @Type='" + param.Type + "',@AreaType='" + param.AreaType + "'";
            var reportModel = StoredProcedure <ReportModel> .Execute(sp, new StoredProcedureParams()).ToList();

            return(reportModel);
        }
Exemplo n.º 9
0
        public bool ValidateLogin()
        {
            bool result;

            StoredProcedure proc = new StoredProcedure(Constants.CONNECTION_STRING, Constants.STORED_PROC_VALIDATE_LOGIN);

            proc.AddInput("@userName", UserName.Trim(), System.Data.SqlDbType.VarChar);
            proc.AddInput("@password", Password.Trim(), System.Data.SqlDbType.VarChar);

            System.Data.SqlClient.SqlParameter idParam = proc.AddOutput("@userId", System.Data.SqlDbType.Int);

            result = proc.Execute();

            if (result)
            {
                if (idParam.Value != DBNull.Value)
                {
                    UserId = Convert.ToInt32(idParam.Value);
                }
                else
                {
                    UserId = 0;
                }
            }
            else
            {
                UserId = 0;
            }

            return(result);
        }
Exemplo n.º 10
0
 private void cmdLuuLai_Click(object sender, EventArgs e)
 {
     foreach (Janus.Windows.GridEX.GridEXRow grdExRow in grdPresDetail.GetDataRows())
     {
         int IdCapPhatCt   = Utility.Int32Dbnull(grdExRow.Cells[TPhieuCapphatNoitruCt.Columns.IdCapPhatCt].Value);
         int presdetail_id = Utility.Int32Dbnull(grdExRow.Cells[TPhieuCapphatNoitruCt.Columns.IdDonthuocCtiet].Value);
         int soluong       = Utility.Int32Dbnull(grdExRow.Cells[TPhieuCapphatNoitruCt.Columns.SoLuong].Value);
         int DaLinh        = Utility.Int32Dbnull(grdExRow.Cells[TPhieuCapphatNoitruCt.Columns.DaLinh].Value);
         // int value = Utility.Int32Dbnull(e.Value);
         StoredProcedure sp = SPs.DuocUpdateLinhSoLuongThuoc(IdCapPhatCt, presdetail_id, DaLinh);
         sp.Execute();
         var query = from thuoc in m_dtPhieuCapPhatLichSuCT.AsEnumerable()
                     where
                     Utility.Int32Dbnull(TPhieuCapphatNoitruCt.Columns.IdCapPhatCt) ==
                     Utility.Int32Dbnull(grdExRow.Cells[TPhieuCapphatNoitruCt.Columns.IdCapPhatCt].Value)
                     select thuoc;
         if (query.Any())
         {
             var firstrow = query.FirstOrDefault();
             if (firstrow != null)
             {
                 firstrow[TPrescriptionDetail.Columns.SluongLinh] = soluong == 1 ? soluong : 0;
                 firstrow.AcceptChanges();
             }
         }
         grdPresDetail.UpdateData();
     }
 }
Exemplo n.º 11
0
        public bool UpdatePassword(string oldPassword)
        {
            bool result;

            StoredProcedure proc = new StoredProcedure(Constants.CONNECTION_STRING, Constants.STORED_PROC_CHANGE_PASSWORD);

            proc.AddInput("@userId", UserId, System.Data.SqlDbType.Int);
            proc.AddInput("@oldPassword", oldPassword.Trim(), System.Data.SqlDbType.VarChar);
            proc.AddInput("@newPassword", Password.Trim(), System.Data.SqlDbType.VarChar);

            System.Data.SqlClient.SqlParameter resultParam = proc.AddOutput("@result", System.Data.SqlDbType.Bit);

            result = proc.Execute();

            if (result)
            {
                result = Convert.ToBoolean(resultParam.Value);

                if (!result)
                {
                    throw new Exception("Old password incorrect.");
                }
            }

            return(result);
        }
        /// <summary>
        /// Begin search process.
        /// </summary>
        public void BeginSearch()
        {
            Guid   operationId          = DeduplicationConsts.SearchOperationId;
            bool   isFeatureEnable      = _userConnection.GetIsFeatureEnabled("FindDuplicatesOnSave");
            string tspFindDuplicateName = string.Format(FindDuplicateProcedurePattern, _schemaName);

            if (isFeatureEnable)
            {
                tspFindDuplicateName = string.Format(FindDuplicateProcedurePattern, String.Empty);
            }
            if (!Locker.CanExecute(operationId, _schemaName))
            {
                return;
            }
            Guid conversationId = ConversationProvider.BeginConversation(tspFindDuplicateName);

            try {
                Locker.SetLockState(conversationId, _schemaName, operationId, true);
                var storedProcedure = new StoredProcedure(_userConnection, tspFindDuplicateName);
                if (isFeatureEnable)
                {
                    storedProcedure.WithParameter("schemaName", _schemaName);
                    storedProcedure.WithParameter("xmlRows", String.Empty);
                    storedProcedure.WithParameter("sysAdminUnit", _userConnection.CurrentUser.Id);
                }
                storedProcedure.Execute();
                ConversationProvider.EndConversation(conversationId);
                CreateSuccessReminding();
            } catch (Exception e) {
                ConversationProvider.EndConversationWithError(conversationId, CommonSqlExceptionCode, e.Message);
                CreateReminding(_userConnection.GetLocalizableString("DeduplicationActionHelper", "FaildDuplicatesSearchMessage"));
            } finally {
                Locker.SetLockState(conversationId, _schemaName, operationId, false);
            }
        }
Exemplo n.º 13
0
 private void LaySokham(int status, TextBox lblQMSNumber, string MaKhoa, string madoituongkcb, int IsUuTien, ref string qmsNumber)
 {
     try
     {
         int             num       = 0;
         int             sttkham   = 0;
         StoredProcedure procedure = SPs.QmsTaoso(new int?(status), _QMSProperties.MaQuay, MaKhoa, id_KhoaKcb, madoituongkcb, new int?(num), sttkham, _QMSProperties.PrintStatus ? true : false, 0, new int?(IsUuTien), this.id_kieukham, this.id_phongkham, id_dichvukcb);
         procedure.Execute();
         int SttKham = Utility.Int32Dbnull(procedure.OutputValues[1]);
         UpdateSTTKham(SttKham);
         num = Utility.Int32Dbnull(procedure.OutputValues[0]);
         string str = Utility.sDbnull(num);
         if (Utility.Int32Dbnull(num) < 10)
         {
             str = Utility.FormatNumberToString(num, "00");
         }
         qmsNumber = str;
         if (_OnCreatedQMSNumber != null)
         {
             _OnCreatedQMSNumber(str);
         }
         str = Utility.sDbnull(SttKham);
         if (Utility.Int32Dbnull(SttKham) < 10)
         {
             str = Utility.FormatNumberToString(SttKham, "00");
         }
         lblQMSNumber.Text = Utility.sDbnull(str);
     }
     catch (Exception ex)
     {
         Utility.ShowMsg("Lỗi khi thực hiện lấy số thứ tự tiếp đón\n" + ex.Message);
     }
 }
Exemplo n.º 14
0
 public void ThemPhieuXuatTH(DPhieuXuatBnhan objectPhieuxuatBN)
 {
     try
     {
         DPhieuXuatBnhan _phieuxuatBN = new DPhieuXuatBnhan();
         _phieuxuatBN       = objectPhieuxuatBN;
         _phieuxuatBN.IsNew = true;
         _phieuxuatBN.Save();
         StoredProcedure sp = SPs.DPhieuXuatBnhanInsert(objectPhieuxuatBN.IdPhieuXuatBn,
                                                        objectPhieuxuatBN.MaPhieuXuatBn,
                                                        objectPhieuxuatBN.NgayXuatBn, objectPhieuxuatBN.NgayKeDon,
                                                        objectPhieuxuatBN.TenBenhnhan, objectPhieuxuatBN.TenKhongDau,
                                                        objectPhieuxuatBN.Gtinh, objectPhieuxuatBN.ChanDoan,
                                                        objectPhieuxuatBN.MaBenh, objectPhieuxuatBN.DiaChi,
                                                        objectPhieuxuatBN.NamSinh, objectPhieuxuatBN.SoThe,
                                                        objectPhieuxuatBN.IdDoiTuong,
                                                        objectPhieuxuatBN.IdNhanVien,
                                                        objectPhieuxuatBN.IdDonThuoc, objectPhieuxuatBN.IdKhoaCd,
                                                        objectPhieuxuatBN.IdBacsiKedon, objectPhieuxuatBN.IdKhoXuat,
                                                        objectPhieuxuatBN.HienThi, objectPhieuxuatBN.NoiTru,
                                                        objectPhieuxuatBN.LoaiDthuoc, objectPhieuxuatBN.TrangThai,
                                                        objectPhieuxuatBN.Ngaytao, objectPhieuxuatBN.NguoiTao,
                                                        objectPhieuxuatBN.LoaiPhieu);
         sp.Execute();
         objectPhieuxuatBN.IdPhieuXuatBn = Utility.Int32Dbnull(sp.OutputValues[0]);
         // return ActionResult.Success;
     }
     catch (Exception)
     {
     }
 }
        /// <summary>
        /// Removes table from DB or makes it empty if is needed.
        /// </summary>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="userConnection">User connection instance.</param>
        /// <param name="truncateData">Truncate table if this is needed.</param>
        public static void DropTable(string tableName, UserConnection userConnection, bool truncateData)
        {
            var sp = new StoredProcedure(userConnection, "tsp_DropOrTruncateTable");

            sp.WithParameter("tableName", tableName);
            sp.WithParameter("isTruncate", truncateData ? 1 : 0);
            sp.Execute();
        }
        /// <summary>
        /// Calculate completeness for records by completeness Id.
        /// </summary>
        /// <param name="completenessId">Completeness Id.</param>
        public virtual void RecalculateAllByCompleteness(Guid completenessId)
        {
            StoredProcedure recalculateAllBySchema =
                new StoredProcedure(AppConnection.SystemUserConnection, "tsp_CompletenessRenew")
                .WithParameter(new QueryParameter("CompletenessId", completenessId, "Guid")) as StoredProcedure;

            recalculateAllBySchema.PackageName = "tspkg_Completeness";
            recalculateAllBySchema.Execute();
        }
        /// <summary>
        /// Activate bulk emails used in campaign
        /// </summary>
        /// <param name="campaignId">Unique identifier of campaign.</param>
        /// <param name="userConnection">User connection.</param>
        private void ActivateReferencedCampaignEmails(Guid campaignId, UserConnection userConnection)
        {
            var storedProcedure = new StoredProcedure(UserConnection, "tsp_ActivateBulkEmailByCampaign");

            storedProcedure.WithParameter(campaignId);
            using (DBExecutor dbExecutor = userConnection.EnsureDBConnection()) {
                storedProcedure.Execute(dbExecutor);
            }
        }
Exemplo n.º 18
0
        public static bool BhytKiemtratruockhiHuyinphoiBHYT(long Id_benhnhan, string ma_luotkham)
        {
            int             _outvalue = -1;
            StoredProcedure sp        = SPs.BhytKiemtratruockhiHuyinphoiBHYT(Id_benhnhan, ma_luotkham, _outvalue);

            sp.Execute();
            _outvalue = Utility.Int32Dbnull(sp.OutputValues[0]);
            return(_outvalue == 0);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Moves records group to ignore list.
        /// </summary>
        /// <param name="schemaName">Schema name.</param>
        /// <param name="deduplicateRecordIds">Unique identifiers.</param>
        public void AddToIgnoreList(string schemaName, List <string> deduplicateRecordIds)
        {
            string duplicateRecordIdsToString = string.Join(",", deduplicateRecordIds.ToArray());
            var    storedProcedure            = new StoredProcedure(_userConnection, "tsp_AddDuplicatesToIgnoreList");

            storedProcedure.WithParameter("SchemaName", schemaName);
            storedProcedure.WithParameter("Duplicates", duplicateRecordIdsToString);
            storedProcedure.Execute();
        }
Exemplo n.º 20
0
 public void Store(TestResult testResult)
 {
     using (
         var storedProcedure = new StoredProcedure(DataBase.Default, "sp_InsertResults",
                                                   SetUpResultParameters(testResult)))
     {
         storedProcedure.Execute();
     }
 }
Exemplo n.º 21
0
        /// <summary>
        /// hàm thực hiện việc xác nhận thông tin
        /// </summary>
        /// <param name="objPhieuNhap"></param>
        /// <returns></returns>
        public ActionResult HuyXacNhanPhieuNhapKho(TPhieuNhapxuatthuoc objPhieuNhap, ref string errMsg)
        {
            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        SqlQuery sqlQuery = new Select().From(TPhieuNhapxuatthuocChitiet.Schema)
                                            .Where(TPhieuNhapxuatthuocChitiet.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu);
                        TPhieuNhapxuatthuocChitietCollection objPhieuNhapCtCollection =
                            sqlQuery.ExecuteAsCollection <TPhieuNhapxuatthuocChitietCollection>();

                        foreach (TPhieuNhapxuatthuocChitiet objPhieuNhapCt in objPhieuNhapCtCollection)
                        {
                            ActionResult kiemtrathuochuyxacnhan = Kiemtrathuochuyxacnhan(objPhieuNhap, objPhieuNhapCt);
                            if (kiemtrathuochuyxacnhan != ActionResult.Success)
                            {
                                return(kiemtrathuochuyxacnhan);
                            }
                            //Xóa toàn bộ chi tiết trong TBiendongThuoc
                            new Delete().From(TBiendongThuoc.Schema)
                            .Where(TBiendongThuoc.IdPhieuColumn).IsEqualTo(objPhieuNhap.IdPhieu)
                            .And(TBiendongThuoc.IdPhieuChitietColumn).IsEqualTo(objPhieuNhapCt.IdPhieuchitiet)
                            .And(TBiendongThuoc.MaLoaiphieuColumn).IsEqualTo(objPhieuNhap.LoaiPhieu).Execute();

                            new Update(TPhieuNhapxuatthuocChitiet.Schema).Set(TPhieuNhapxuatthuocChitiet.Columns.IdThuockho).EqualTo(-1)
                            .Set(TPhieuNhapxuatthuocChitiet.Columns.NgayNhap).EqualTo(null)
                            .Where(TPhieuNhapxuatthuocChitiet.Columns.IdPhieuchitiet).IsEqualTo(objPhieuNhapCt.IdPhieuchitiet).Execute();

                            StoredProcedure sp = SPs.ThuocXuatkho(objPhieuNhap.IdKhonhap, objPhieuNhapCt.IdThuoc,
                                                                  objPhieuNhapCt.NgayHethan, objPhieuNhapCt.GiaNhap, objPhieuNhapCt.GiaBan,
                                                                  Utility.DecimaltoDbnull(objPhieuNhap.Vat), objPhieuNhapCt.SoLuong,
                                                                  objPhieuNhapCt.IdThuockho, objPhieuNhapCt.MaNhacungcap, objPhieuNhapCt.SoLo,
                                                                  0, errMsg);

                            sp.Execute();
                        }

                        new Update(TPhieuNhapxuatthuoc.Schema)
                        .Set(TPhieuNhapxuatthuoc.Columns.IdNhanvien).EqualTo(-1)
                        .Set(TPhieuNhapxuatthuoc.Columns.NguoiXacnhan).EqualTo(null)
                        .Set(TPhieuNhapxuatthuoc.Columns.NgayXacnhan).EqualTo(null)
                        .Set(TPhieuNhapxuatthuoc.Columns.TrangThai).EqualTo(0)
                        .Where(TPhieuNhapxuatthuoc.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu).Execute();
                    }
                    Scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException("Lỗi khi hủy xác nhận nhập kho", ex);
                return(ActionResult.Error);
            }
        }
Exemplo n.º 22
0
        public ActionResult HuyXacNhanPhieuHuy_thanhly_Thuoc(TPhieuNhapxuatthuoc objPhieuNhap, ref string errMsg)
        {
            HisDuocProperties objHisDuocProperties = PropertyLib._HisDuocProperties;
            string            errorMessage         = "";

            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        SqlQuery sqlQuery = new Select().From(TPhieuNhapxuatthuocChitiet.Schema)
                                            .Where(TPhieuNhapxuatthuocChitiet.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu);
                        TPhieuNhapxuatthuocChitietCollection objPhieuNhapCtCollection =
                            sqlQuery.ExecuteAsCollection <TPhieuNhapxuatthuocChitietCollection>();

                        foreach (TPhieuNhapxuatthuocChitiet objPhieuNhapCt in objPhieuNhapCtCollection)
                        {
                            long idthuockho = -1;
                            //Nhập lại kho thanh lý
                            StoredProcedure sp = SPs.ThuocNhapkhoOutput(objPhieuNhapCt.NgayHethan, objPhieuNhapCt.GiaNhap, objPhieuNhapCt.GiaBan,
                                                                        objPhieuNhapCt.SoLuong, Utility.DecimaltoDbnull(objPhieuNhapCt.Vat),
                                                                        objPhieuNhapCt.IdThuoc, objPhieuNhap.IdKhoxuat, objPhieuNhapCt.MaNhacungcap, objPhieuNhapCt.SoLo,
                                                                        objPhieuNhapCt.SoDky, objPhieuNhapCt.SoQdinhthau, idthuockho, idthuockho, objPhieuNhapCt.NgayNhap, objPhieuNhapCt.GiaBhyt, objPhieuNhapCt.GiaPhuthuDungtuyen, objPhieuNhapCt.GiaPhuthuTraituyen, objPhieuNhapCt.KieuThuocvattu);
                            sp.Execute();
                            idthuockho = Utility.Int64Dbnull(sp.OutputValues[0], -1);
                            if (idthuockho != objPhieuNhapCt.IdThuockho)//Nếu ai đó xóa bằng tay trong bảng thuốc kho thì cần update lại
                            {
                                new Update(TPhieuNhapxuatthuocChitiet.Schema).Set(TPhieuNhapxuatthuocChitiet.Columns.IdThuockho).EqualTo(idthuockho)
                                .Where(TPhieuNhapxuatthuocChitiet.Columns.IdPhieuchitiet).IsEqualTo(objPhieuNhapCt.IdPhieuchitiet).Execute();
                            }
                        }
                        //Xóa toàn bộ chi tiết trong TBiendongThuoc
                        new Delete().From(TBiendongThuoc.Schema)
                        .Where(TBiendongThuoc.IdPhieuColumn).IsEqualTo(objPhieuNhap.IdPhieu)
                        .And(TBiendongThuoc.MaLoaiphieuColumn).IsEqualTo(objPhieuNhap.LoaiPhieu).Execute();
                        new Update(TPhieuNhapxuatthuoc.Schema)
                        .Set(TPhieuNhapxuatthuoc.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                        .Set(TPhieuNhapxuatthuoc.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                        .Set(TPhieuNhapxuatthuoc.Columns.NguoiXacnhan).EqualTo(null)
                        .Set(TPhieuNhapxuatthuoc.Columns.NgayXacnhan).EqualTo(null)
                        .Set(TPhieuNhapxuatthuoc.Columns.TrangThai).EqualTo(0)
                        .Where(TPhieuNhapxuatthuoc.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu)
                        .And(TPhieuNhapxuatthuoc.LoaiPhieuColumn).IsEqualTo(objPhieuNhap.LoaiPhieu).Execute();
                    }
                    Scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException("Lỗi khi hủy xác nhận phiếu ", ex);
                return(ActionResult.Error);
            }
        }
Exemplo n.º 23
0
 public string GetPatientCode()
 {
     string MaxPatientCode = "";
     StoredProcedure sp = SPs.SpGetPatientCode(MaxPatientCode);
     sp.Execute();
     sp.OutputValues.ForEach(delegate(object objOutput)
     {
         MaxPatientCode = (String)objOutput;
     });
     return MaxPatientCode;
 }
Exemplo n.º 24
0
 public string GetPatientID(string sNgayThucHien, string MaDonVi)
 {
     string PatientID = "";
     StoredProcedure sp = SPs.SpGeneratePatientID(sNgayThucHien, MaDonVi, PatientID);
     sp.Execute();
     sp.OutputValues.ForEach(delegate(object objOutput)
     {
         PatientID = (String)objOutput;
     });
     return PatientID;
 }
Exemplo n.º 25
0
        /// <summary>
        /// Runs stored procedure.
        /// </summary>
        /// <param name="userConnection">User connection instance.</param>
        /// <param name="spName">Stored procedure name.</param>
        /// <param name="parameters">Execution params.</param>
        /// <returns>Execution results.</returns>
        public static int ExecuteStoredProcedure(UserConnection userConnection, string spName,
                                                 params KeyValuePair <string, object>[] parameters)
        {
            var sp = new StoredProcedure(userConnection, spName);

            foreach (var parameter in parameters)
            {
                sp.WithParameter(parameter.Key, parameter.Value);
            }
            return(sp.Execute());
        }
Exemplo n.º 26
0
        public void LaySoKhamQMS(string MaQuay, string MaKhoa, string madoituongkcb, ref int SoKham, ref int idDichvukcb, ref int idQMS, byte uutien, int loaiqms, string loaiqmsbo)
        {
            SoKham      = 0;
            idDichvukcb = 0;
            StoredProcedure sp = SPs.QmsLayso(MaQuay, MaKhoa, madoituongkcb, SoKham, idDichvukcb, idQMS, uutien, loaiqms, loaiqmsbo);

            sp.Execute();
            SoKham      = Utility.Int32Dbnull(sp.OutputValues[0]);
            idDichvukcb = Utility.Int32Dbnull(sp.OutputValues[1]);
            idQMS       = Utility.Int32Dbnull(sp.OutputValues[2]);
        }
Exemplo n.º 27
0
        public virtual bool SearchForDuplicatesScriptTaskExecute(ProcessExecutingContext context)
        {
            var accountSchemaName = "Account";
            var storedProcedure   = new StoredProcedure(UserConnection, "tsp_GloballySearchForDuplicates");

            storedProcedure.WithParameter(Column.Const(accountSchemaName));
            using (var dbExecutor = UserConnection.EnsureDBConnection()) {
                storedProcedure.Execute(dbExecutor);
            }
            return(true);
        }
        public void ExecutionStpUploadBayersFromFtp(string pathToBayersFile, string pathToInActivCardsFile, string pathToOursFile, string pathToScheduleFile, string pathToProdsFile)
        {
            var uploadBuyersFromFtp = new StoredProcedure(userConnection, "tsp_UploadFromFtp");

            uploadBuyersFromFtp.WithParameter("PathToBayersFile", pathToBayersFile);
            uploadBuyersFromFtp.WithParameter("PathInActivCardsFile", pathToInActivCardsFile);
            uploadBuyersFromFtp.WithParameter("PathOursFile", pathToOursFile);
            uploadBuyersFromFtp.WithParameter("PathSheduleFile", pathToScheduleFile);
            uploadBuyersFromFtp.WithParameter("PathProdsFile", pathToProdsFile);
            uploadBuyersFromFtp.PackageName = "ITS";
            uploadBuyersFromFtp.Execute();
        }
        /// <summary>
        /// Moves contact onto required step of the campaign.
        /// </summary>
        /// <param name="userConnection">Instance of the <see cref="Terrasoft.Core.UserConnection"/>.</param>
        /// <param name="campaignId">Unique identifier of the Campaign.</param>
        /// <param name="stepId">Unique identifier of the CampaignStep.</param>
        /// <param name="contactId">Unique identifier of the Contact.</param>
        public static void MergeContactIntoCampaign(UserConnection userConnection, Guid campaignId, Guid stepId,
                                                    Guid contactId)
        {
            var sp = new StoredProcedure(userConnection, "tsp_CampaignStepHandler_MergeContactIntoCampaign");

            sp.WithParameter("CampaignId", campaignId);
            sp.WithParameter("StepId", stepId);
            sp.WithParameter("ContactId", contactId);
            using (var dbExecutor = userConnection.EnsureDBConnection()) {
                sp.Execute(dbExecutor);
            }
        }
Exemplo n.º 30
0
        public virtual void SetCustomRecordPosition(string tableName, Guid primaryColumnValue, string grouppingColumnNames, int position)
        {
            var setRecordPositionProcedure = new StoredProcedure(_userConnection, "tsp_SetRecordPosition")
                                             .WithParameter("TableName", tableName)
                                             .WithParameter("PrimaryColumnName", "Id")
                                             .WithParameter("PrimaryColumnValue", primaryColumnValue)
                                             .WithParameter("GrouppingColumnNames", grouppingColumnNames)
                                             .WithParameter("Position", position) as StoredProcedure;

            setRecordPositionProcedure.PackageName = _userConnection.DBEngine.SystemPackageName;
            setRecordPositionProcedure.Execute();
        }
Exemplo n.º 31
0
 public void SP_Should_Execute_Without_Parameter2()
 {
     StoredProcedure sp = new StoredProcedure("Ten Most Expensive Products", DataService.Providers["Northwind"]);
     int count = 0;
     using (IDataReader rdr =sp.GetReader())
     {
         while (rdr.Read())
             count++;
         rdr.Close();
     }
     sp.Execute();
     Assert.IsTrue(count > 0);
 }
Exemplo n.º 32
0
        public void SP_Outputs_DefaultProvider()
        {
            StoredProcedure sp = new StoredProcedure("SubSonicTestNW", DataService.GetInstance("Northwind"));
            sp.Command.AddOutputParameter("@param");
            sp.Execute();

            //make sure there's outputs
            Assert.IsTrue(sp.OutputValues.Count > 0);

            //this SP just returns today's date.
            //make sure it's right now!
            DateTime dTest = Convert.ToDateTime(sp.OutputValues[0]);
            Assert.IsTrue(dTest.Date == DateTime.Now.Date);
        }
        public void TestTransaction()
        {
            using (DbConnection connection = GetConnection())
            {
                connection.Open();

                DbTransaction transaction = connection.BeginTransaction();

                const string newName = "changed";

                StoredProcedure changeName = new StoredProcedure("ChangeName");
                changeName.Command.AddParameter("@Id", 2, DbType.Int32, 4);
                changeName.Command.AddParameter("@NewName", newName, DbType.String, 50);
                changeName.Execute(transaction);

                StoredProcedure getName = new StoredProcedure("GetName");
                getName.Command.AddParameter("@Id", 2, DbType.Int32, 4);
                Assert.AreEqual(newName, getName.ExecuteScalar(transaction), "The name has not been changed");

                transaction.Rollback();

                Assert.AreEqual("name2", getName.ExecuteScalar(), "The name has not been reverted");

                connection.Close();
            }
        }
        public void TestOutputParameterGeneric()
        {
            StoredProcedure sp = new StoredProcedure("OutputParameter", "default");
            sp.Command.AddParameter("@First", 2, DbType.Int32, 4);
            sp.Command.AddParameter("@Second", 3, DbType.Int32, 4);
            sp.Command.AddOutParameter("@Result", DbType.Int32, 4);

            int result;
            sp.Execute(out result);

            Assert.AreEqual(5, result);
        }