public void Add()
        {
            AddingControls.CreateEditWindow W = new AddingControls.CreateEditWindow(DatabaseContext, TableType, Fields);
            W.ShowDialog();

            DataGrid.DataContext = DatabaseContext.GetTable(TableType);
        }
Exemple #2
0
        public virtual void Update(T Obj)
        {
            UserEngine.SessionTimeOut();
            T NewObj = default(T);

            HelperLinq.ModeDetail('u', Obj);
            if (Standard.GetTable(Obj.GetType()).GetOriginalEntityState(Obj) == null)
            {
                NewObj = Detach(Obj);
                Standard.GetTable(Obj.GetType()).Attach(NewObj, true);
            }
        }
Exemple #3
0
        public string UpdateOrInsert()
        {
            try
            {
                var Table = DatabaseContext.GetTable <SymptomsDiagnose>();

                SymptomsDiagnose SD = new SymptomsDiagnose();
                string           SymptomsSelectedItem  = (string)cmbSymptoms.SelectedItem;
                string           DiagnosesSelectedItem = (string)cmbDiagnoses.SelectedItem;
                SD.SymptomID  = Convert.ToInt32(SymptomsSelectedItem.Substring(0, SymptomsSelectedItem.IndexOf(' ')));
                SD.DiagnoseID = Convert.ToInt32(DiagnosesSelectedItem.Substring(0, DiagnosesSelectedItem.IndexOf(' ')));
                SD.ProbabYes  = (double)nudYes.Value;
                SD.ProbabNo   = (double)nudNo.Value;

                var Queue = from T in Table
                            where (T.SymptomID == SD.SymptomID && T.DiagnoseID == SD.DiagnoseID)
                            select T;
                if (Queue.Count() != 0)
                {
                    return("Такое правило уже существует. Пара Симптом-Диагноз должна быть уникальной");
                }

                Table.InsertOnSubmit(SD);
            }
            catch (Exception Ex)
            {
                return("Неизвестная ошибка: " + Ex.Message);
            }
            return(null);
        }
        protected override List <ExpenditureRecord> GetingItems(System.Data.Linq.DataContext dc, SearchCondition search)
        {
            IQueryable <ExpenditureRecord> ret = dc.GetTable <ExpenditureRecord>();

            if (search is SheetSearchCondition)
            {
                SheetSearchCondition con = search as SheetSearchCondition;
                if (con.SheetDate != null)
                {
                    ret = ret.Where(item => item.SheetDate >= con.SheetDate.Begin && item.SheetDate <= con.SheetDate.End);
                }
                if (con.LastActiveDate != null)
                {
                    ret = ret.Where(item => item.LastActiveDate >= con.LastActiveDate.Begin && item.LastActiveDate <= con.LastActiveDate.End);
                }
                if (con.SheetNo != null && con.SheetNo.Count > 0)
                {
                    ret = ret.Where(item => con.SheetNo.Contains(item.ID));
                }
                if (con.States != null && con.States.Count > 0)
                {
                    ret = ret.Where(item => con.States.Contains(item.State));
                }
            }
            if (search is ExpenditureRecordSearchCondition)
            {
                ExpenditureRecordSearchCondition con = search as ExpenditureRecordSearchCondition;
                if (!string.IsNullOrEmpty(con.Category))
                {
                    ret = ret.Where(item => item.Category.Contains(con.Category));
                }
            }
            return(ret.ToList());
        }
        protected override List <DeviceReadLog> GetingItems(System.Data.Linq.DataContext dc, SearchCondition search)
        {
            IQueryable <DeviceReadLog> ret = dc.GetTable <DeviceReadLog>();

            if (search is DeviceReadLogSearchCondition)
            {
                var con = search as DeviceReadLogSearchCondition;
                if (con.ReadDateRange != null)
                {
                    ret = ret.Where(it => it.ReadDate >= con.ReadDateRange.Begin && it.ReadDate <= con.ReadDateRange.End);
                }
                if (!string.IsNullOrEmpty(con.DeviceID))
                {
                    ret = ret.Where(it => it.DeviceID == con.DeviceID);
                }
                if (con.Devices != null && con.Devices.Count > 0)
                {
                    ret = ret.Where(it => con.Devices.Contains(it.DeviceID));
                }
                if (con.DeviceType.HasValue)
                {
                    ret = ret.Where(it => it.DeviceType == con.DeviceType.Value);
                }
            }
            return(ret.ToList());
        }
        protected override List <ProductInventory> GetingItems(System.Data.Linq.DataContext dc, SearchCondition search)
        {
            IQueryable <ProductInventory> ret = dc.GetTable <ProductInventory>();

            if (search is ProductInventorySearchCondition)
            {
                ProductInventorySearchCondition con = search as ProductInventorySearchCondition;
                if (!string.IsNullOrEmpty(con.WareHouseID))
                {
                    ret = ret.Where(item => item.WareHouseID.Contains(con.WareHouseID));
                }
                if (!string.IsNullOrEmpty(con.ProductID))
                {
                    ret = ret.Where(item => item.ProductID.Contains(con.ProductID));
                }
            }
            List <ProductInventory> items = ret.ToList();

            if (items != null && items.Count > 0)
            {
                List <Product>   ps = (new ProductProvider(ConnectStr, _MappingResource)).GetItems(null).QueryObjects;
                List <WareHouse> ws = (new WareHouseProvider(ConnectStr, _MappingResource)).GetItems(null).QueryObjects;
                foreach (ProductInventory pi in items)
                {
                    pi.Product   = ps.SingleOrDefault(p => p.ID == pi.ProductID);
                    pi.WareHouse = ws.SingleOrDefault(w => w.ID == pi.WareHouseID);
                }
            }
            return(items);
        }
Exemple #7
0
        protected ServiceResult HandleException(Exception ex, User user)
        {
            ServerError error = new ServerError()
            {
                ErrorMessage = ex.Message,
                DateCreated  = DateTime.Now,
            };

            if (user != null)
            {
                error.UserId   = user.UserId;
                error.UserName = user.UserName;
            }
            //HACK The saving of errors needs to be refactored. The reason for the below code is because we need to
            //create a new context, as the DB one has thrown an exception, therefore we are not able to use it any longer to save.
            //That's why the error is being saved in the first place i.e. because an exception has been thrown.
            using (System.Data.Linq.DataContext ctx = new System.Data.Linq.DataContext(LINQOptions.Instance.Settings.ConnectionString))
            {
                ctx.GetTable <ServerError>().InsertOnSubmit(error);
                ctx.SubmitChanges();
            }
            ServiceException serviceException = ex as ServiceException;

            if (serviceException == null)
            {
                return(new ServiceResult {
                    Code = ServiceResultCode.FatalError, Message = ex.Message
                });                                                                                     //Not a user thrown exception.
            }
            else
            {
                return(serviceException.Result);
            }
        }
Exemple #8
0
        private void SortAuthorClick(object sender, EventArgs e)
        {
            System.Data.Linq.DataContext db = new System.Data.Linq.DataContext(connectionString);

            var query = from u in db.GetTable <Book>()
                        orderby u.AuthorFIO
                        select u;
        }
Exemple #9
0
 private void Search_Click(object sender, EventArgs e)
 {
     System.Data.Linq.DataContext db = new System.Data.Linq.
                                       DataContext(Properties.Resources.ConnectionString);
     Resultatas.DataSource =
         db.GetTable <Lektuva>().
         Where(x => x.AtvykimoVieta == KryptisText.Text &&
               x.Isvykimas.Date > dateTimePicker1.Value);
 }
Exemple #10
0
 private void Resultatas_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 4)
     {
         //Antra klase
         Vieta vieta = new Vieta();
         vieta.firstclass = false;
         System.Data.Linq.DataContext db = new System.Data.Linq.
                                           DataContext(Properties.Resources.ConnectionString);
         var lektuvas = db.GetTable <Lektuva>().Where(x => x.Id ==
                                                      (int)Resultatas.Rows[e.RowIndex].Cells[0].Value);
         lektuvas.First().AntrosKlasesVietuSkaicius--;
         var user = db.GetTable <User>().Where(x => x.Id == UserId);
         user.First().Vietas.Add(vieta);
         lektuvas.First().Vietas.Add(vieta);
         db.GetTable <Vieta>().InsertOnSubmit(vieta);
         db.SubmitChanges();
         MessageBox.Show("Jus sekmingai atlikote rezervacija");
     }
     else if (e.ColumnIndex == 3)
     {
         Vieta vieta = new Vieta();
         vieta.firstclass = true;
         System.Data.Linq.DataContext db = new System.Data.Linq.
                                           DataContext(Properties.Resources.ConnectionString);
         var lektuvas = db.GetTable <Lektuva>().Where(x => x.Id ==
                                                      (int)Resultatas.Rows[e.RowIndex].Cells[0].Value);
         lektuvas.First().PirmosKlasesVietuSkaicius--;
         var user = db.GetTable <User>().Where(x => x.Id == UserId);
         user.First().Vietas.Add(vieta);
         lektuvas.First().Vietas.Add(vieta);
         db.GetTable <Vieta>().InsertOnSubmit(vieta);
         db.SubmitChanges();
         MessageBox.Show("Jus sekmingai atlikote rezervacija");
     }
 }
Exemple #11
0
        public SymptomDiagnoseAddEdit(System.Data.Linq.DataContext DatabaseContext)
        {
            InitializeComponent();

            this.DatabaseContext = DatabaseContext;

            var           Queue    = from S in DatabaseContext.GetTable <Symptom>() select S;
            List <string> Symptoms = new List <string>(Queue.Count());

            foreach (var Q in Queue)
            {
                Symptoms.Add(Q.ID + " " + Q.Name);
            }
            cmbSymptoms.ItemsSource = Symptoms;

            var           Queue1    = from S in DatabaseContext.GetTable <Diagnose>() select S;
            List <string> Diagnoses = new List <string>(Queue1.Count());

            foreach (var Q in Queue1)
            {
                Diagnoses.Add(Q.ID + " " + Q.Name);
            }
            cmbDiagnoses.ItemsSource = Diagnoses;
        }
        private void RegistruotisMygtukas_Click(object sender, EventArgs e)
        {
            User user = new User()
            {
                Vardas   = NameText.Text,
                Pavarde  = SurnameText.Text,
                UserName = UserNameText.Text,
                Password = PassWordName.Text
            };
            string connection = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\User\Documents\GitHub\C--kursas-20190923\Rezervacijo\Rezervacijo\RezervacijosDB.mdf;Integrated Security=True";

            System.Data.Linq.DataContext db = new System.Data.Linq.DataContext(connection);
            db.GetTable <User>().InsertOnSubmit(user);
            db.SubmitChanges();
            Close();
        }
        protected override List <Contact> GetingItems(System.Data.Linq.DataContext dc, SearchCondition search)
        {
            IQueryable <Contact> ret = dc.GetTable <Contact>();

            if (search is ContactSearchCondition)
            {
                ContactSearchCondition con = search as ContactSearchCondition;
                if (!string.IsNullOrEmpty(con.CompanyID))
                {
                    ret = ret.Where(item => item.Company == con.CompanyID);
                }
            }
            List <Contact> cs = ret.ToList();

            return(cs);
        }
Exemple #14
0
        private void Connect_Click(object sender, EventArgs e)
        {
            System.Data.Linq.DataContext db = new System.Data.Linq.DataContext(connection);
            var user = db.GetTable <User>().
                       Where(x => x.UserName == UserNameText.Text && x.Password == PassWordText.Text);

            if (user.Count() == 0)
            {
                MessageBox.Show("Nerastas toks vartotojas");
            }
            else
            {
                RezervacijosForma form = new RezervacijosForma(connection, user.First().Id);
                form.Show();
                WindowState = FormWindowState.Minimized;
            }
        }
 private void btnDelete_Click(object sender, RoutedEventArgs e)
 {
     if (DataGrid != null)
     {
         if (DataGrid.SelectedItem != null)
         {
             if (MessageBox.Show(@"Вы действительно хотите удалить эту запись", "Удаление", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
             {
                 var Table = DatabaseContext.GetTable(TableType);
                 Table.DeleteOnSubmit(DataGrid.SelectedItem);
                 DatabaseContext.SubmitChanges();
                 DatabaseContext      = new System.Data.Linq.DataContext(ConnectionString);
                 DataGrid.DataContext = DatabaseContext.GetTable(TableType);
             }
         }
     }
 }
        protected override List <CustomerReceivable> GetingItems(System.Data.Linq.DataContext dc, SearchCondition search)
        {
            IQueryable <CustomerReceivable> ret = dc.GetTable <CustomerReceivable>();

            if (search is CustomerReceivableSearchCondition)
            {
                CustomerReceivableSearchCondition con = search as CustomerReceivableSearchCondition;
                if (con.CreateDate != null)
                {
                    ret = ret.Where(item => item.CreateDate >= con.CreateDate.Begin && item.CreateDate <= con.CreateDate.End);
                }
                if (con.ReceivableTypes != null && con.ReceivableTypes.Count > 0)
                {
                    ret = ret.Where(item => con.ReceivableTypes.Contains(item.ClassID));
                }
                if (con.ReceivableIDS != null && con.ReceivableIDS.Count > 0)
                {
                    ret = ret.Where(item => con.ReceivableIDS.Contains(item.ID));
                }
                if (!string.IsNullOrEmpty(con.CustomerID))
                {
                    ret = ret.Where(item => item.CustomerID == con.CustomerID);
                }
                if (!string.IsNullOrEmpty(con.OrderID))
                {
                    ret = ret.Where(item => item.OrderID == con.OrderID);
                }
                if (!string.IsNullOrEmpty(con.SheetID))
                {
                    ret = ret.Where(item => item.SheetID == con.SheetID);
                }
                if (con.Settled != null)
                {
                    if (con.Settled.Value)
                    {
                        ret = ret.Where(item => item.Haspaid == item.Amount);
                    }
                    else
                    {
                        ret = ret.Where(item => item.Haspaid < item.Amount);
                    }
                }
            }
            return(ret.ToList());
        }
Exemple #17
0
        protected override List <AttachmentHeader> GetingItems(System.Data.Linq.DataContext dc, SearchCondition search)
        {
            IQueryable <AttachmentHeader> ret = dc.GetTable <AttachmentHeader>();

            if (search is AttachmentSearchCondition)
            {
                AttachmentSearchCondition con = search as AttachmentSearchCondition;
                if (!string.IsNullOrEmpty(con.DocumentID))
                {
                    ret = ret.Where(item => item.DocumentID == con.DocumentID);
                }
                if (!string.IsNullOrEmpty(con.DocumentType))
                {
                    ret = ret.Where(item => item.DocumentType == con.DocumentType);
                }
            }
            return(ret.ToList());
        }
        protected override List <CustomerPaymentAssign> GetingItems(System.Data.Linq.DataContext dc, SearchCondition search)
        {
            IQueryable <CustomerPaymentAssign> ret = dc.GetTable <CustomerPaymentAssign>();

            if (search is CustomerPaymentAssignSearchCondition)
            {
                CustomerPaymentAssignSearchCondition con = search as CustomerPaymentAssignSearchCondition;
                if (!string.IsNullOrEmpty(con.PaymentID))
                {
                    ret = ret.Where(item => item.PaymentID == con.PaymentID);
                }
                if (con.ReceivableIDs != null && con.ReceivableIDs.Count > 0)
                {
                    ret = ret.Where(item => con.ReceivableIDs.Contains(item.ReceivableID));
                }
            }
            return(ret.ToList());
        }
        internal static bool DeleteWithCascase <T>(System.Data.Linq.DataContext ctx, T entity) where T : class, INotifyPropertyChanged
        {
            //Get the primary key of the context
            var pkey = GetPrimaryKey <T>();
            //Get foreign keys
            var fkeys = GetForeignKeys <T>();
            //get the model for the ctx
            var model = new AttributeMappingSource().GetModel(ctx.GetType());
            //Get the table for the given entity
            var eTable = ctx.GetTable <T>();

            foreach (var modelTable in model.GetTables())
            {
                //Loop tables and delete
            }

            return(true);
        }
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            if (DataGrid.SelectedItem != null)
            {
                //DatabaseContext = new System.Data.Linq.DataContext(ConnectionString);
                AddingControls.CreateEditWindow W = new AddingControls.CreateEditWindow(DatabaseContext, DataGrid.SelectedItem, Fields);
                W.ShowDialog();

                if (!W.CancelClick)
                {
                    DatabaseContext = new System.Data.Linq.DataContext(ConnectionString);
                    if (DataGrid != null)
                    {
                        DataGrid.DataContext = DatabaseContext.GetTable(TableType);
                    }
                }
            }
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            DatabaseContext = new System.Data.Linq.DataContext(ConnectionString);
            AddingControls.CreateEditWindow W;

            /* if (TableType == typeof(SymptomsDiagnose))
             *   W = new HospitalClient.DatabaseControls.SymptomDiagnoseAddEdit(DatabaseContext);
             * else*/
            W = new AddingControls.CreateEditWindow(DatabaseContext, TableType, Fields);
            W.ShowDialog();

            if (!W.CancelClick)
            {
                DatabaseContext = new System.Data.Linq.DataContext(ConnectionString);
                if (DataGrid != null)
                {
                    DataGrid.DataContext = DatabaseContext.GetTable(TableType);
                }
            }
        }
        //***************************************************************************
        // Private Methods
        //
        private static bool CheckEntityIsAttached <T>(System.Data.Linq.DataContext ctx, T entity)
            where T : rsEntityBase, new()
        {
            // This is *SO* much simpler than the old way I was doing it, it's not even funny.
            System.Data.Linq.Table <T> entityTbl = ctx.GetTable <T>();
            return(entityTbl.GetOriginalEntityState(entity) != null);

            #region DEPRECIATED - This old method is a cluster, and has been deemed stupid, thanks to me realizing the context will give me the table for a given entity
            //// NOTE:  This is a fairly expensive method call, since it's performing
            ////   two seperate reflection lookups.

            //// Get the Type of the passed entity.
            //Type entityType = entity.GetType();
            //string entitiyTypeName = entityType.Name;

            //// Generally, the Linq2Sql table names are the 'plural' form of the entity names.
            //string srchName = (entitiyTypeName.EndsWith("y") ? entitiyTypeName.TrimEnd('y') + "ies" : entitiyTypeName + "s");

            //// Try and find the context's property that the passed entity was queried
            ////   from.  This method is *far* from fool-proof.
            //System.Reflection.PropertyInfo piTableProperty = ctx.GetType().GetProperty(srchName, bindingFlagsPublicInstance);
            //if (piTableProperty == null)
            //    throw new MemberAccessException(string.Format("Unable to locate property '{0}' in data context.", srchName));

            //// If we found the table property, we need to get the value of the property, and
            ////   locate the static 'GetOriginalEntityState' method.
            //object ctxTable = piTableProperty.GetValue(ctx, null);
            //Type ctxTableType = ctxTable.GetType();

            //System.Reflection.MethodInfo miGetEntityState = ctxTableType.GetMethod("GetOriginalEntityState", new Type[] { entityType });
            //if (miGetEntityState == null)
            //    throw new MemberAccessException(string.Format("Unable to locate 'GetOriginalEntityState' method in Type '{0}'.", ctxTableType.Name));

            //// If all of that worked out, we just have to call (invoke) the method, and pass
            ////   the supplied entity as a parameter.  If we get a 'null' back, then the entity
            ////   is not attached to the context.
            //object miReturn = miGetEntityState.Invoke(ctxTable, new object[] { entity });

            //return miReturn != null;
            #endregion
        }
 /// <summary>
 /// Extension method for DataContext objects that determine if the object is already contained in the DataContext
 /// </summary>
 /// <param name="item">The entity to check existance for</param>
 /// <returns>True if the Entity exists otherwise false</returns>
 public static bool IsValid <T>(this System.Data.Linq.DataContext dataContext, T item) where T : class, System.ComponentModel.INotifyPropertyChanged
 {
     if (null == item)
     {
         return(false);
     }
     try
     {
         System.Data.Linq.Table <T> table = dataContext.GetTable <T>();
         if (table == null)
         {
             return(false);
         }
         else
         {
             return(table.Contains(item));
         }
     }
     catch
     {
         return(false);
     }
 }
Exemple #24
0
        void ButtonOk_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var Table = DatabaseContext.GetTable(TableType);

                if (Creating)
                {
                    Result = Activator.CreateInstance(TableType);
                }

                foreach (KeyValuePair <string, PropertyInfo> Pair in Fields)
                {
                    object Value = GetValue(ValueItems["item" + Pair.Value.Name], Pair.Value.PropertyType);
                    if (Pair.Value.Name == "ID" && Value == null)
                    {
                        Value = ((int)DatabaseContext.ExecuteQuery <int>("select max(ID) from " + TableType.Name + "s").First() + 1).ToString();
                    }
                    Pair.Value.SetValue(Result, Value, new object[0]);
                }

                if (Creating)
                {
                    Table.InsertOnSubmit(Result);
                }
                DatabaseContext.SubmitChanges();

                CancelClick = false;

                Close();
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message);
            }
        }
Exemple #25
0
        protected override List <YouhuiQuan> GetingItems(System.Data.Linq.DataContext dc, SearchCondition search)
        {
            IQueryable <YouhuiQuan> ret = dc.GetTable <YouhuiQuan>();

            if (search is YouhuiQuanSearchCondition)
            {
                YouhuiQuanSearchCondition con = search as YouhuiQuanSearchCondition;
                if (!string.IsNullOrEmpty(con.YouhuiID))
                {
                    ret = ret.Where(item => item.YouhuiID == con.YouhuiID);
                }
                if (!string.IsNullOrEmpty(con.User))
                {
                    ret = ret.Where(item => item.User == con.User);
                }
                if (con.CreateDate != null)
                {
                    ret = ret.Where(item => item.CreateDate >= con.CreateDate.Begin && item.CreateDate <= con.CreateDate.End);
                }
                if (!string.IsNullOrEmpty(con.Proxy))
                {
                    ret = ret.Where(it => it.Proxy == con.Proxy);
                }
                if (con.ComsumeDate != null)
                {
                    ret = ret.Where(item => item.ComsumeDate >= con.ComsumeDate.Begin && item.ComsumeDate <= con.ComsumeDate.End);
                }
                if (con.CanUseNow != null && con.CanUseNow.Value)
                {
                    ret = ret.Where(item => item.ComsumeDate == null && (item.From == null || item.From.Value <= DateTime.Now) && (item.To == null || item.To >= DateTime.Now));
                }
            }
            List <YouhuiQuan> cs = ret.ToList();

            return(cs);
        }
Exemple #26
0
        protected override List <CompanyInfo> GetingItems(System.Data.Linq.DataContext dc, SearchCondition search)
        {
            IQueryable <CompanyInfo> ret = dc.GetTable <CompanyInfo>();

            if (search is CustomerSearchCondition)
            {
                CustomerSearchCondition con = search as CustomerSearchCondition;
                if (!string.IsNullOrEmpty(con.CustomerID))
                {
                    ret = ret.Where(item => item.ID.Contains(con.CustomerID));
                }
                if (con.ClassID != null)
                {
                    ret = ret.Where(item => item.ClassID == con.ClassID.Value);
                }
                if (!string.IsNullOrEmpty(con.Category))
                {
                    ret = ret.Where(item => item.CategoryID == con.Category);
                }
            }
            List <CompanyInfo> cs = ret.ToList();

            return(cs);
        }
Exemple #27
0
        protected override List <AlarmInfo> GetingItems(System.Data.Linq.DataContext dc, SearchCondition search)
        {
            IQueryable <AlarmInfo> result = dc.GetTable <AlarmInfo>();

            if (search is AlarmSearchCondition)
            {
                AlarmSearchCondition con = search as AlarmSearchCondition;
                if (con.AlarmDateTime != null)
                {
                    result = result.Where(c => c.AlarmDateTime >= con.AlarmDateTime.Begin);
                    result = result.Where(c => c.AlarmDateTime <= con.AlarmDateTime.End);
                }
                if (con.AlarmType != null)
                {
                    result = result.Where(c => c.AlarmType == con.AlarmType);
                }
                if (con.OperatorID != null)
                {
                    result = result.Where(c => c.OperatorID == con.OperatorID);
                }
            }
            result = result.OrderBy(item => item.AlarmDateTime);
            return(result.ToList());
        }
Exemple #28
0
        protected override List <CustomerOtherReceivable> GetingItems(System.Data.Linq.DataContext dc, SearchCondition search)
        {
            IQueryable <CustomerOtherReceivable> ret = dc.GetTable <CustomerOtherReceivable>();

            if (search is SheetSearchCondition)
            {
                SheetSearchCondition con = search as SheetSearchCondition;
                if (con.SheetDate != null)
                {
                    ret = ret.Where(item => item.SheetDate >= con.SheetDate.Begin && item.SheetDate <= con.SheetDate.End);
                }
                if (con.LastActiveDate != null)
                {
                    ret = ret.Where(item => item.LastActiveDate >= con.LastActiveDate.Begin && item.LastActiveDate <= con.LastActiveDate.End);
                }
                if (con.SheetNo != null && con.SheetNo.Count > 0)
                {
                    ret = ret.Where(item => con.SheetNo.Contains(item.ID));
                }
                if (con.States != null && con.States.Count > 0)
                {
                    ret = ret.Where(item => con.States.Contains(item.State));
                }
            }
            if (search is CustomerOtherReceivableSearchCondition)
            {
                CustomerOtherReceivableSearchCondition con = search as CustomerOtherReceivableSearchCondition;
                if (!string.IsNullOrEmpty(con.CustomerID))
                {
                    ret = ret.Where(item => item.CustomerID == con.CustomerID);
                }
            }
            List <CustomerOtherReceivable> items = ret.ToList();

            return(items);
        }
Exemple #29
0
 protected override AttachmentHeader GetingItemByID(Guid id, System.Data.Linq.DataContext dc)
 {
     return(dc.GetTable <AttachmentHeader>().SingleOrDefault(item => item.ID == id));
 }
Exemple #30
0
 protected override CurrencyType GetingItemByID(string id, System.Data.Linq.DataContext dc)
 {
     return(dc.GetTable <CurrencyType>().SingleOrDefault(item => item.ID == id));
 }