//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); }
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); }