Esempio n. 1
0
        public List <AnalyzerInfo> getAllAnalyzer(int pageSize, int pageIndex, AnalyzerSeachCriteria _criteria)
        {
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                List <AnalyzerInfo> ListAnalyzer = AnalyzerDataLayer.GetInstance().getAnalyzer(connection, _criteria);
                int min = pageIndex * pageSize;
                int max = pageIndex * pageSize + pageSize;

                if (min > ListAnalyzer.Count)
                {
                    return(new List <AnalyzerInfo>());
                }
                if (max >= ListAnalyzer.Count)
                {
                    pageSize = ListAnalyzer.Count - min;
                }
                if (pageSize <= 0)
                {
                    return(new List <AnalyzerInfo>());
                }
                return(ListAnalyzer.GetRange(min, pageSize));
            }
        }
Esempio n. 2
0
        public int getTotalRecords(AnalyzerSeachCriteria _criteria)
        {
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                return(AnalyzerDataLayer.GetInstance().getTotalRecords(connection, _criteria));
            }
        }
Esempio n. 3
0
        public List <string> getListAnalyzerCode(string AnalyzerCode)
        {
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                List <string> ListAnalyzer = AnalyzerDataLayer.GetInstance().getListAnalyzerCode(connection, AnalyzerCode);
                return(ListAnalyzer);
            }
        }
Esempio n. 4
0
        public AnalyzerInfo getAnalyzer(int _ID)
        {
            AnalyzerInfo         record        = new AnalyzerInfo();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                record = AnalyzerDataLayer.GetInstance().getAnalyzer(connection, _ID);
                if (record == null)
                {
                    return(null);
                }
                return(record);
            }
        }
Esempio n. 5
0
        public AnalyzerInfo GetAnalyzerByCode(string code)
        {
            AnalyzerInfo         record        = new AnalyzerInfo();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                record = AnalyzerDataLayer.GetInstance().GetAnalyzerByCode(connection, code);
                if (record == null)
                {
                    return(null);
                }

                return(record);
            }
        }
Esempio n. 6
0
        public List <AnalyzerInfo> GetAnalyzerByDate(AnalyzerSeachCriteria date)
        {
            List <AnalyzerInfo>  record        = new List <AnalyzerInfo>();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                record = AnalyzerDataLayer.GetInstance().GetAnalyzerByDate(connection, date);
                if (record == null)
                {
                    return(null);
                }

                return(record);
            }
        }
Esempio n. 7
0
        public ActionMessage DeleteMuti(string ids)
        {
            ActionMessage ret = new ActionMessage();

            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    AnalyzerDataLayer.GetInstance().DeleteMuti(connection, ids);
                    ret.isSuccess = true;
                }
                catch (Exception ex)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "Internal Error";
                    ret.err.msgString = ex.Message;
                }
            }
            return(ret);
        }
Esempio n. 8
0
        public async Task <ActionMessage> editAnalyzer(int id, AnalyzerInfo _Analyzer, string _userU)
        {
            ActionMessage        ret           = new ActionMessage();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                var chkAnalyzerInfo = AnalyzerDataLayer.GetInstance().getAnalyzer(connection, id);
                if (chkAnalyzerInfo != null)
                {
                    try
                    {
                        AnalyzerDataLayer.GetInstance().UpdateAnalyzer(connection, id, _Analyzer, _userU);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                ret.isSuccess = true;
                return(ret);
            }
        }
Esempio n. 9
0
        public async Task <ActionMessage> Create(DeliveryReceiptInfo obj, [FromForm] List <IFormFile> files, string _userI, string _userID)
        {
            ActionMessage        ret           = new ActionMessage();
            int                  insetId       = -1;
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    insetId = DeliveryReceiptDataLayer.GetInstance().Create(connection, obj, _userI);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            if (insetId > -1)
            {
                ret.id = insetId;
                using (SqlConnection connection = sqlConnection.GetConnection())
                {
                    try
                    {
                        if (obj.Items != null)
                        {
                            // insertEmployees(insetId, obj.Employees);
                            foreach (DeliveryReceiptItemInfoNew item in obj.Items)
                            {
                                item.DeliveryReceiptID = insetId;
                                if (item.Amount > 0)
                                {
                                    //input tai san
                                    DeliveryReceiptWithDepartment deliveryReceipt = DeliveryReceiptDataLayer.GetInstance().getItemCreateAna(connection, item.DeliveryReceiptID, _userID);
                                    AnalyzerInfo analyzerInfo = new AnalyzerInfo()
                                    {
                                        AnalyzerAccountantCode = "",
                                        AnalyzerName           = item.ItemName,
                                        AnalyzerType           = 0,

                                        QuoteItemID = item.QuoteItemID,
                                        Description = "",

                                        Amount           = item.Amount,
                                        ItemPrice        = item.ItemPrice,
                                        TotalPrice       = item.TotalPrice,
                                        DepartmentRootID = deliveryReceipt.DepartmentID,
                                        DepartmentID     = deliveryReceipt.DepartmentID,

                                        ContractCode  = deliveryReceipt.ContractCode,
                                        UserIContract = deliveryReceipt.UserIContract,
                                        CustomerID    = deliveryReceipt.CustomerID,
                                        CustomerName  = deliveryReceipt.CustomerName,

                                        ExpirationDate    = DateTime.Now,
                                        DateIn            = obj.DeliveryReceiptDate,
                                        DeliveryReceiptID = item.DeliveryReceiptID,
                                        Serial            = "",
                                    };

                                    int seq      = AnalyzerDataLayer.GetInstance().GetMaxPropCode(connection, analyzerInfo.DateIn.Year);
                                    int insertID = AnalyzerDataLayer.GetInstance().InsertAnalyzer(connection, analyzerInfo, seq, _userI);

                                    string[] _anaNamesSplit = analyzerInfo.AnalyzerName.Split(' ');
                                    string   _anaNameSplit  = "";
                                    for (int i = 0; i < _anaNamesSplit.Count(); i++)
                                    {
                                        if (i == 4)
                                        {
                                            break;
                                        }
                                        else
                                        {
                                            _anaNameSplit += (_anaNamesSplit[i][0]).ToString().ToUpper();
                                        }
                                    }
                                    string anacode = _anaNameSplit + "." + analyzerInfo.DateIn.Year + "." + String.Format("{0:000000}", seq);
                                    AnalyzerDataLayer.GetInstance().UpdateAnalyzer(connection, insertID, anacode);
                                    // end insert
                                    DeliveryReceiptDataLayer.GetInstance().CreateDeliveryReceiptItem(connection, item, _userI);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }

                using (SqlConnection connection = sqlConnection.GetConnection())
                {
                    try
                    {
                        if (obj.Employees != null)
                        {
                            foreach (DeliveryReceiptEmployeeInfo item in obj.Employees)
                            {
                                item.DeliveryReceiptID = insetId;
                                DeliveryReceiptDataLayer.GetInstance().CreateDeliveryReceiptItemUser(connection, item, _userI);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }

                foreach (var item in files)
                {
                    DocumentInfo documentInfo = new DocumentInfo();
                    documentInfo.TableName = TableFile.DeliveryReceipt.ToString();
                    documentInfo.PreferId  = insetId.ToString();
                    documentInfo.Link      = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName);
                    documentInfo.FileName  = item.FileName;
                    documentInfo.Length    = item.Length.ToString();
                    documentInfo.Type      = item.ContentType;
                    ret = await FilesHelpers.UploadFile(TableFile.DeliveryReceipt.ToString(), insetId.ToString(), item, documentInfo.Link);

                    DocumentService.GetInstance().InsertDocument(documentInfo, _userI.ToString());
                }
                ret.isSuccess = true;
            }
            else
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "lỗi thêm phiếu nghiệm thu";
                ret.err.msgString = "lỗi thêm phiếu nghiệm thu";
            }
            return(ret);
        }