public int CompareTo(object obj) { Category3Info b = obj as Category3Info; if (this.Status < b.Status) { return(1); } else if (this.Status > b.Status) { return(-1); } else { int result = String.Compare(this.C3ID, b.C3ID); if (result > 0) { return(1); } else { return(-1); } } }
public void Insert(Category3Info oParam) { //foreach( Category3Info item in C3Hash.Values ) //{ // if ( item.C3ID == oParam.C3ID ) // throw new BizException("the same third category ID exists"); //} string _c2ID = ""; string _c3ID = ""; int _tmpInt = -1; string _tmpStr = ""; Category2Info _oC2 = CategoryManager.GetInstance().GetC2Hash()[oParam.C2SysNo] as Category2Info; if (_oC2.C2ID.Trim() == "") throw new BizException("�Բ������������Ŵ��������"); _c2ID = _oC2.C2ID.Trim(); string sql = "select max(C3ID) from Category3 where c3id like '" + _c2ID + "%'"; _tmpStr = SqlHelper.ExecuteScalar(sql).ToString(); if (_tmpStr.Trim() == "") _tmpStr = _c2ID + "00"; if (_tmpStr.Length != 6) throw new BizException("�Բ�������С���Ŵ��������"); _tmpStr = _tmpStr.Substring(4, 2); if (!Util.IsInteger(_tmpStr)) throw new BizException("�Բ�������С���Ŵ��������"); _tmpInt = Convert.ToInt32(_tmpStr); if (_tmpInt >= 99)//��λ��� { throw new BizException("�Բ��𣬱��Խ�磬���������"); } _tmpInt++; if (_tmpInt < 10) _c3ID = _c2ID + "0" + _tmpInt.ToString(); else _c3ID = _c2ID + _tmpInt.ToString(); oParam.C3ID = _c3ID; oParam.SysNo = SequenceDac.GetInstance().Create("Category_Sequence"); new CategoryDac().Insert(oParam); SyncManager.GetInstance().SetDbLastVersion( (int)AppEnum.Sync.Category ); C3Hash.Add(oParam.SysNo, oParam); }
public void ImportCategory() { if ( !AppConfig.IsImportable) throw new BizException("Is Importable is false"); /* do not use the following code after Data Pour in */ string sql = " select top 1 * from category1 "; DataSet ds = SqlHelper.ExecuteDataSet(sql); if ( Util.HasMoreRow(ds) ) throw new BizException("the table category is not empty"); TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { try { string sql1 = @"select cf.*, cfl.firstcategoryname from ipp2003..category_first cf, ipp2003..category_first_language cfl where cf.sysno = cfl.firstcategorysysno and languageid = 'cn'"; DataSet ds1 = SqlHelper.ExecuteDataSet(sql1); foreach(DataRow dr1 in ds1.Tables[0].Rows ) { Category1Info oC1 = new Category1Info(); oC1.C1ID = Util.TrimNull(dr1["FirstCategoryID"]); oC1.C1Name = Util.TrimNull(dr1["FirstCategoryName"]); oC1.Status = Util.TrimIntNull(dr1["Status"]); this.Insert(oC1); //insert into convert table ImportInfo oC1Convert = new ImportInfo(); oC1Convert.OldSysNo = Util.TrimIntNull(dr1["SysNo"]); oC1Convert.NewSysNo = oC1.SysNo; new ImportDac().Insert(oC1Convert, "Category1"); string sql2 = @"select a.*, b.secondcategoryname from ipp2003..category_second a, ipp2003..category_second_language b where a.sysno = b.secondcategorysysno and languageid = 'cn' and firstcategorysysno = " + Util.TrimIntNull(dr1["SysNo"]); DataSet ds2 = SqlHelper.ExecuteDataSet(sql2); foreach( DataRow dr2 in ds2.Tables[0].Rows ) { Category2Info oC2 = new Category2Info(); oC2.C1SysNo = oC1.SysNo; oC2.C2ID = Util.TrimNull(dr2["SecondCategoryID"]); oC2.C2Name = Util.TrimNull(dr2["SecondCategoryName"]); oC2.Status = Util.TrimIntNull(dr2["Status"]); this.Insert(oC2); //insert into convert table ImportInfo oC2Convert = new ImportInfo(); oC2Convert.OldSysNo = Util.TrimIntNull(dr2["SysNo"]); oC2Convert.NewSysNo = oC2.SysNo; new ImportDac().Insert(oC2Convert,"Category2"); string sql3 = @"select a.*, b.thirdcategoryname from ipp2003..category_third a, ipp2003..category_third_language b where a.sysno = b.thirdcategorysysno and languageid = 'cn' and secondcategorysysno = "+ Util.TrimIntNull(dr2["SysNo"]); DataSet ds3 = SqlHelper.ExecuteDataSet(sql3); foreach( DataRow dr3 in ds3.Tables[0].Rows ) { Category3Info oC3 = new Category3Info(); oC3.C2SysNo = oC2.SysNo; oC3.C3ID = Util.TrimNull(dr3["ThirdCategoryID"]); oC3.C3Name = Util.TrimNull(dr3["ThirdCategoryName"]); oC3.Status = Util.TrimIntNull(dr3["Status"]); this.Insert(oC3); //insert into convert table ImportInfo oC3Convert = new ImportInfo(); oC3Convert.OldSysNo = Util.TrimIntNull(dr3["SysNo"]); oC3Convert.NewSysNo = oC3.SysNo; new ImportDac().Insert(oC3Convert, "Category3"); string sql4 = @"select a.*,b.AttributeName from ipp2003..category_attribute as a, ipp2003..category_attribute_language as b where a.ThirdCategorySysNo = b.ThirdCategorySysNo and a.AttributeID = b.AttributeID and languageid = 'cn' and AttributeName <>'' and a.thirdcategorysysno = "+ Util.TrimIntNull(dr3["SysNo"]); DataSet ds4 = SqlHelper.ExecuteDataSet(sql4); int count = 0; foreach( DataRow dr4 in ds4.Tables[0].Rows ) { if ( count == 0) { InitAttribute(Util.TrimIntNull(oC3.SysNo)); count ++; } CategoryAttributeInfo oCA = new CategoryAttributeInfo(); oCA.C3SysNo = oC3.SysNo; oCA.AttributeID = Util.TrimNull(dr4["AttributeID"]); oCA.AttributeName = Util.TrimNull(dr4["AttributeName"]); oCA.OrderNum = Util.TrimIntNull(dr4["SequenceNo"]); oCA.Status = Util.TrimIntNull(dr4["Status"]); new CategoryDac().UpdateAttributeByC3andAID(oCA); } } } } } catch(Exception ex) { C1Hash.Clear(); C2Hash.Clear(); C3Hash.Clear(); throw ex; } scope.Complete(); } }
private void Map(Category3Info oParam, DataRow tempdr) { oParam.SysNo = Util.TrimIntNull(tempdr["SysNo"]); oParam.C2SysNo = Util.TrimIntNull(tempdr["C2SysNo"]); oParam.C3ID = Util.TrimNull(tempdr["C3ID"]); oParam.C3Name = Util.TrimNull(tempdr["C3Name"]); oParam.Status = Util.TrimIntNull(tempdr["Status"]); oParam.Online = Util.TrimIntNull(tempdr["Online"]); oParam.C3InventoryCycleTime = Util.TrimIntNull(tempdr["C3InventoryCycleTime"]); oParam.C3DMSWeight = Util.TrimDecimalNull(tempdr["C3DMSWeight"]); }
private void InitC3() { lock( categoryLocker ) { C3Hash.Clear(); string sql = " select * from category3 order by sysno"; DataSet ds = SqlHelper.ExecuteDataSet(sql); if ( !Util.HasMoreRow(ds)) return; foreach( DataRow dr in ds.Tables[0].Rows ) { Category3Info item = new Category3Info(); Map(item, dr); C3Hash.Add(item.SysNo, item); } } }
public void Update(Category3Info oParam) { //foreach(Category3Info item in C3Hash.Values) //{ // if ( item.SysNo!=oParam.SysNo && item.C3ID == oParam.C3ID) // throw new BizException("the same third category ID exists"); //} new CategoryDac().Update(oParam); SyncManager.GetInstance().SetDbLastVersion( (int)AppEnum.Sync.Category ); if ( C3Hash.ContainsKey(oParam.SysNo)) { C3Hash.Remove(oParam.SysNo); C3Hash.Add(oParam.SysNo, oParam); } }
public int Update(Category3Info oParam) { string sql = @"UPDATE Category3 SET C2SysNo=@C2SysNo, C3ID=@C3ID, C3Name=@C3Name, Status=@Status,Online=@Online, C3InventoryCycleTime=@C3InventoryCycleTime,C3DMSWeight=@C3DMSWeight WHERE SysNo=@SysNo"; SqlCommand cmd = new SqlCommand(sql); SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int,4); SqlParameter paramC2SysNo = new SqlParameter("@C2SysNo", SqlDbType.Int,4); SqlParameter paramC3ID = new SqlParameter("@C3ID", SqlDbType.NVarChar,20); SqlParameter paramC3Name = new SqlParameter("@C3Name", SqlDbType.NVarChar,200); SqlParameter paramStatus = new SqlParameter("@Status", SqlDbType.Int,4); SqlParameter paramOnline = new SqlParameter("@Online", SqlDbType.Int,4); SqlParameter paramC3InventoryCycleTime = new SqlParameter("@C3InventoryCycleTime", SqlDbType.Int, 4); SqlParameter paramC3DMSWeight = new SqlParameter("@C3DMSWeight", SqlDbType.Decimal, 2); paramSysNo.Value = oParam.SysNo; paramC2SysNo.Value = oParam.C2SysNo; paramC3ID.Value = oParam.C3ID; paramC3Name.Value = oParam.C3Name; paramStatus.Value = oParam.Status; paramOnline.Value = oParam.Online; paramC3InventoryCycleTime.Value = oParam.C3InventoryCycleTime; paramC3DMSWeight.Value = oParam.C3DMSWeight; cmd.Parameters.Add(paramSysNo); cmd.Parameters.Add(paramC2SysNo); cmd.Parameters.Add(paramC3ID); cmd.Parameters.Add(paramC3Name); cmd.Parameters.Add(paramStatus); cmd.Parameters.Add(paramOnline); cmd.Parameters.Add(paramC3InventoryCycleTime); cmd.Parameters.Add(paramC3DMSWeight); return SqlHelper.ExecuteNonQuery(cmd); }
public int Insert(Category3Info oParam) { string sql = @"INSERT INTO Category3 ( SysNo, C2SysNo, C3ID, C3Name, Status,Online, C3InventoryCycleTime,C3DMSWeight ) VALUES ( @SysNo, @C2SysNo, @C3ID, @C3Name, @Status,@Online, @C3InventoryCycleTime,@C3DMSWeight )"; SqlCommand cmd = new SqlCommand(sql); SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int,4); SqlParameter paramC2SysNo = new SqlParameter("@C2SysNo", SqlDbType.Int,4); SqlParameter paramC3ID = new SqlParameter("@C3ID", SqlDbType.NVarChar,20); SqlParameter paramC3Name = new SqlParameter("@C3Name", SqlDbType.NVarChar,200); SqlParameter paramStatus = new SqlParameter("@Status", SqlDbType.Int,4); SqlParameter paramOnline = new SqlParameter("@Online", SqlDbType.Int,4); SqlParameter paramC3InventoryCycleTime = new SqlParameter("@C3InventoryCycleTime", SqlDbType.Int, 4); SqlParameter paramC3DMSWeight = new SqlParameter("@C3DMSWeight", SqlDbType.Decimal, 2); paramSysNo.Value = oParam.SysNo; paramC2SysNo.Value = oParam.C2SysNo; paramC3ID.Value = oParam.C3ID; paramC3Name.Value = oParam.C3Name; paramStatus.Value = oParam.Status; paramOnline.Value = oParam.Online; paramC3InventoryCycleTime.Value = oParam.C3InventoryCycleTime; paramC3DMSWeight.Value = oParam.C3DMSWeight; cmd.Parameters.Add(paramSysNo); cmd.Parameters.Add(paramC2SysNo); cmd.Parameters.Add(paramC3ID); cmd.Parameters.Add(paramC3Name); cmd.Parameters.Add(paramStatus); cmd.Parameters.Add(paramOnline); cmd.Parameters.Add(paramC3InventoryCycleTime); cmd.Parameters.Add(paramC3DMSWeight); return SqlHelper.ExecuteNonQuery(cmd); }
/// <summary> /// ������ƷInventoryCycleTime��DMSWeight /// </summary> /// <param name="oInfo"></param> /// <param name="isAll"></param> /// <returns></returns> public int UpdateProductDMSBasicByC3(Category3Info oInfo, bool isAll) { string sql = "update product set InventoryCycleTime='" + oInfo.C3InventoryCycleTime + "',DMSWeight='" + oInfo.C3DMSWeight + "' where c3sysno=" + oInfo.SysNo; if (!isAll) { sql += " and (InventoryCycleTime is null or len(InventoryCycleTime) = 0 or DMSWeight is null or len(DMSWeight) = 0)"; } return SqlHelper.ExecuteNonQuery(sql); }