Ejemplo n.º 1
0
        //public bool IfHaveCountStockDailyDocument(CDBUtil dbUtil, MySqlConnection conn, int shopId)
        //{
        //    string sql = "SELECT * FROM document WHERE DocumentID=" + DocumentId + " AND shopid=" + shopId
        //        + " AND documenttypeid=24 AND documentstatus=1";
        //    MySqlDataReader reader = dbUtil.sqlRetrive(sql, conn);
        //    if (reader.Read())
        //    {
        //        reader.Close();
        //        return true;
        //    }
        //    else
        //        reader.Close();
        //    return false;
        //}

        public virtual bool AddAdjustDocument(CDBUtil dbUtil, MySqlConnection conn)
        {
            string sql = " INSERT INTO document (DocumentID, ShopID, DocumentTypeID, DocumentYear, DocumentMonth, " +
                         " DocumentNumber, DocumentDate, InputBy, UpdateBy, ApproveBy, DocumentStatus, DocumentIDRef, " +
                         " DocIDRefShopID, ProductLevelID, ToInvID, FromInvID, Remark, InsertDate, UpdateDate, ApproveDate) " +
                         " VALUES(" + DocumentId + ", " + ShopId + ", " + DocumentTypeId + ", " +
                         DocumentYear + ", " + DocumentMonth + ", " + DocumentNumber + ", '" +
                         DocumentDate.ToString("yyyy'-'MM'-'dd", dateProvider) + "', " +
                         InputBy + ", " + UpdateBy + ", " + ApproveBy + ", " + DocumentStatus + ", " + DocumentIdRef + ", " +
                         DocIdRefShopId + ", " + ProductLevelId + ", " + ToInvId + ", " + FromInvId + ", '" + Remark + "', '" +
                         DateTime.Now.ToString("yyyy'-'MM'-'dd HH':'mm':'ss", dateProvider) + "', '" +
                         DateTime.Now.ToString("yyyy'-'MM'-'dd HH':'mm':'ss", dateProvider) + "', '" +
                         DateTime.Now.ToString("yyyy'-'MM'-'dd HH':'mm':'ss", dateProvider) + "')";

            try
            {
                int exec = dbUtil.sqlExecute(sql, conn);
                if (exec > 0)
                {
                    AddMaxDocumentNumber(dbUtil, conn);
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public XElement ToXML()
        {
            var xDocumentInfo = new XElement(Fb2Const.fb2DefaultNamespace + "document-info");

            foreach (AuthorType author in _documentAuthors)
            {
                xDocumentInfo.Add(author.ToXML());
            }
            if (ProgramUsed2Create != null)
            {
                xDocumentInfo.Add(ProgramUsed2Create.ToXML(ProgramUsedElementName));
            }
            if (DocumentDate != null)
            {
                xDocumentInfo.Add(DocumentDate.ToXML());
            }
            foreach (string srcUrl in _sourceUrLs)
            {
                xDocumentInfo.Add(new XElement(Fb2Const.fb2DefaultNamespace + SourceURLElementName, srcUrl));
            }
            if (SourceOCR != null)
            {
                xDocumentInfo.Add(SourceOCR.ToXML(SourceOCRElementName));
            }
            if (!string.IsNullOrEmpty(ID))
            {
                xDocumentInfo.Add(new XElement(Fb2Const.fb2DefaultNamespace + IdElementName, ID));
            }
            if (DocumentVersion != null)
            {
                var cult = new CultureInfo("", false);
                xDocumentInfo.Add(new XElement(Fb2Const.fb2DefaultNamespace + VersionElementName, string.Format(cult.NumberFormat, "{0:F}", DocumentVersion)));
            }
            if (History != null)
            {
                xDocumentInfo.Add(History.ToXML());
            }
            foreach (AuthorType publish in _documentPublishers)
            {
                xDocumentInfo.Add(publish.ToXML());
            }

            return(xDocumentInfo);
        }
Ejemplo n.º 3
0
        public virtual bool AddDocument(CDBUtil dbUtil, MySqlConnection conn)
        {
            string sql = "";

            if (this.DocumentTypeId == 7 || this.DocumentTypeId == 10)
            {
                sql = " SELECT * FROM document WHERE ShopID=" + ShopId +
                      " AND DocumentTypeID = " + DocumentTypeId + " AND DocumentYear=" +
                      this.DocumentYear + " AND DocumentMonth = " + this.DocumentMonth +
                      " AND DocumentStatus=1";
            }
            else if (this.DocumentTypeId == 57)
            {
                StockCountWeeklyDoro scd = new StockCountWeeklyDoro(conn, ShopId, 57);

                string dateFrom = scd.SundayDate();

                sql = " SELECT * FROM document \n" +
                      " WHERE ShopID=" + ShopId + " AND DocumentTypeID=" + DocumentTypeId + "\n" +
                      " AND DocumentDate BETWEEN '" + dateFrom + "' AND \n" +
                      " '" + DateTime.Now.ToString("yyyy-MM-dd", dateProvider) + "' \n" +
                      " AND DocumentStatus=1";
            }
            else
            {
                sql = " SELECT * FROM document WHERE ShopID=" + ShopId +
                      " AND DocumentTypeID = " + DocumentTypeId +
                      " AND DocumentStatus=1  AND DocumentDate=" +
                      " {d '" + this.DocumentDate.ToString("yyyy'-'MM'-'dd", dateProvider) + "'} " +
                      " AND DocumentStatus=1";
            }
            MySqlDataReader reader = dbUtil.sqlRetrive(sql, conn);

            if (reader.Read())
            {
                // Add Docdetail
                if (reader["DocumentID"] != DBNull.Value)
                {
                    DocumentId = Convert.ToInt32(reader["DocumentID"]);
                }
                if (reader["Remark"] != DBNull.Value)
                {
                    Remark = reader.GetString("Remark");
                }

                reader.Close();

                sql = "UPDATE document SET UpdateDate='" + DateTime.Now.ToString("yyyy'-'MM'-'dd HH':'mm':'ss", dateProvider) + "', " +
                      " Remark = '" + Remark + "' WHERE DocumentID=" + DocumentId + " AND ShopID=" + ShopId;
                dbUtil.sqlExecute(sql, conn);

                sql = "DELETE FROM docdetail WHERE DocumentID=" + DocumentId + " AND ShopID=" + ShopId;
                dbUtil.sqlExecute(sql, conn);

                sql = "DELETE FROM docdetailtemp WHERE DocumentID=" + DocumentId + " AND ShopID=" + ShopId;
                dbUtil.sqlExecute(sql, conn);

                return(true);
            }
            else
            {
                reader.Close();
                sql = " INSERT INTO document (DocumentID, ShopID, " +
                      " DocumentTypeID, DocumentYear, DocumentMonth, DocumentNumber, DocumentDate, InputBy, " +
                      " UpdateBy, DocumentStatus, Remark, DocumentIDRef, DocIDRefShopID, ProductLevelID, InsertDate, UpdateDate) " +
                      " VALUES(" + DocumentId + ", " + ShopId + ", " + DocumentTypeId + ", " +
                      DocumentYear + ", " + DocumentMonth + ", " + DocumentNumber + ", '" +
                      DocumentDate.ToString("yyyy'-'MM'-'dd", dateProvider) + "', " +
                      InputBy + ", " + UpdateBy + ", 1, '" + Remark + "', " + DocumentIdRef + ", " + DocIdRefShopId + ", " + ProductLevelId + ", '" +
                      DateTime.Now.ToString("yyyy'-'MM'-'dd HH':'mm':'ss", dateProvider) + "', '" +
                      DateTime.Now.ToString("yyyy'-'MM'-'dd HH':'mm':'ss", dateProvider) + "')";

                try
                {
                    int exec = dbUtil.sqlExecute(sql, conn);
                    if (exec > 0)
                    {
                        // add maxdocumentnumber
                        AddMaxDocumentNumber(dbUtil, conn);
                        return(true);
                    }
                }
                catch
                {
                    return(false);
                }
            }
            return(false);
        }