//MOUSAVI public static EProductPackage SelectByCode(int Code) { SqlConnection connection = new SqlConnection(Atend.Control.ConnectionString.LocalcnString); SqlDataAdapter adapter = new SqlDataAdapter("E_ProductPackage_SelectByCode", connection); adapter.SelectCommand.CommandType = CommandType.StoredProcedure; adapter.SelectCommand.Parameters.Add(new SqlParameter("iCode", Code)); DataSet dsProductPackage = new DataSet(); adapter.Fill(dsProductPackage); EProductPackage ProPck = new EProductPackage(); if (dsProductPackage.Tables[0].Rows.Count > 0) { ProPck.Code = Convert.ToInt32(dsProductPackage.Tables[0].Rows[0]["Code"].ToString()); ProPck.ContainerPackageCode = Convert.ToInt32(dsProductPackage.Tables[0].Rows[0]["ContainerPackageCode"].ToString()); ProPck.Count = Convert.ToInt32(dsProductPackage.Tables[0].Rows[0]["Count"].ToString()); //ProPck.ProductCode = Convert.ToInt32(dsProductPackage.Tables[0].Rows[0]["ProductCode"].ToString()); ProPck.TableType = Convert.ToInt16(dsProductPackage.Tables[0].Rows[0]["TableType"].ToString()); ProPck.XCode = new Guid(dsProductPackage.Tables[0].Rows[0]["XCode"].ToString()); } else { ProPck.Code = -1; } return(ProPck); }
//public static DataTable SelectAllAndMerge() //{ // DataTable AccTbl = AccessSelectAll(); // DataTable SqlTbl = SelectAll(); // DataTable MergeTbl = SqlTbl.Copy(); // DataColumn IsSql = new DataColumn("IsSql", typeof(bool)); // IsSql.DefaultValue = true; // MergeTbl.Columns.Add(IsSql); // foreach (DataRow Dr in AccTbl.Rows) // { // DataRow MergeRow = MergeTbl.NewRow(); // foreach (DataColumn Dc in AccTbl.Columns) // { // MergeRow[Dc.ColumnName] = Dr[Dc.ColumnName]; // } // MergeRow["IsSql"] = false; // MergeRow["XCode"] = new Guid("00000000-0000-0000-0000-000000000000"); // MergeTbl.Rows.Add(MergeRow); // } // return MergeTbl; //} //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// public static bool SentFromLocalToAccess(int Code, Guid XCode, int Type, OleDbTransaction _transaction, OleDbConnection _connection) { int NewCode = 0; try { switch ((Atend.Control.Enum.ProductType)Type) { case Atend.Control.Enum.ProductType.Consol: Atend.Base.Equipment.EConsol SelectedConsol = Atend.Base.Equipment.EConsol.SelectByXCodeForDesign(XCode); if (SelectedConsol.Code != -1) { if (SelectedConsol.AccessInsert(_transaction, _connection, true, false)) { NewCode = SelectedConsol.Code; } else { throw new Exception("SelectedConsol.AccessInsert failed"); } } break; } //aval tazhiz bayad dar jadvale khodesh bere bad Code baraie ContainerCode ersal shavad if (Atend.Base.Equipment.EContainerPackage.SentFromLocalToAccess(XCode, Type, 1, _transaction, _connection)) { EProductPackage SubProducts = Atend.Base.Equipment.EProductPackage.SelectByCode(Code); if (SubProducts.Code != -1) { Atend.Base.Equipment.EProductPackage SelectedSub = Atend.Base.Equipment.EProductPackage.SelectByCode(Code); if (SelectedSub.Code != -1) { SelectedSub.productCode = NewCode; if (!SelectedSub.AccessInsert(_transaction, _connection)) { throw new Exception("SelectedSub.AccessInsert failed"); } } else { //error } //insert access here } else { //error } } else { //error } } catch (System.Exception ex) { return(false); } return(true); }