Exemplo n.º 1
0
 public frmServicesEdit(int?SvcId = null, int?SvcGrp = null)
 {
     InitializeComponent();
     _svc_id  = SvcId;
     _svc_grp = SvcGrp;
     _db      = DB.SkladBase();
 }
Exemplo n.º 2
0
        static public void ShowMatListByWH3(BaseEntities db, WaybillList wb, String WID)
        {
            using (var f = new frmWhCatalog(1))
            {
                f.uc.xtraTabPage4.PageVisible             = false;
                f.uc.xtraTabPage5.PageVisible             = false;
                f.uc.xtraTabPage9.PageVisible             = false;
                f.uc.MatListTabPage.PageVisible           = true;
                f.uc.xtraTabControl1.SelectedTabPageIndex = 4;
                f.uc.gridColumn49.Visible        = false;
                f.uc.gridColumn51.Visible        = false;
                f.uc.gridColumn52.Visible        = false;
                f.uc.MatListGridColumnWh.Visible = (WID == "*");
                f.uc.bar3.Visible = false;
                f.uc.ByWhBtn.Down = true;
                f.uc.splitContainerControl1.SplitterPosition = 0;


                using (var _db = new BaseEntities())
                {
                    int wid;
                    if (int.TryParse(WID, out wid))
                    {
                        f.uc.WHTreeList.DataSource = _db.GetWhTree(DBHelper.CurrentUser.UserId, 2).Where(w => w.GType == 1 && w.Num == wid).ToList();
                    }
                    else
                    {
                        f.uc.WHTreeList.DataSource = _db.GetWhTree(DBHelper.CurrentUser.UserId, 2).Where(w => w.GType == 1).ToList();
                    }
                    f.uc.GrpNameGridColumn.GroupIndex = 0;
                }

                f.uc.wb        = wb;
                f.uc.isMatList = true;
                if (f.ShowDialog() == DialogResult.OK)
                {
                    foreach (var item in f.uc.custom_mat_list)
                    {
                        var wbd = db.WaybillDet.Add(new WaybillDet
                        {
                            WbillId      = wb.WbillId,
                            OnDate       = wb.OnDate,
                            MatId        = item.MatId,
                            WId          = (WID != "*") ? Convert.ToInt32(WID) : item.WId,
                            Amount       = item.Amount,
                            Price        = item.AvgPrice,// item.Price ,
                            Discount     = wb.WType == -20 ? item.Amount : 0,
                            Nds          = wb.Nds,
                            CurrId       = wb.CurrId,
                            OnValue      = wb.OnValue,
                            BasePrice    = item.AvgPrice,// item.Price,
                            PosKind      = 0,
                            PosParent    = 0,
                            DiscountKind = 0
                        });
                    }
                    db.SaveChanges();
                }
            }
        }
Exemplo n.º 3
0
 public Result PostMenuCreate(menu menu)
 {
     try
     {
         db = new BaseEntities();
         int menu_id = Convert.ToInt32(menu.menu_id);
         if (menu_id > 0)
         {
             //menu.is_active = menu.is_active;
             db.Entry(menu).State = System.Data.Entity.EntityState.Modified;
             result.Message       = string.Format(BaseConst.MSG_SUCCESS_UPDATE, "Menu");
         }
         else
         {
             db.menus.Add(menu);
             result.Message = string.Format(BaseConst.MSG_SUCCESS_CREATE, "Menu");
         }
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         result.MessageType = MessageType.Error;
         result.Message     = ex.Message;
     }
     return(result);
 }
Exemplo n.º 4
0
        public Settings create(Settings _settings)
        {
            try
            {
                using (var db = new BaseEntities())
                {
                    Settings newSetting = db.Settings.Add(_settings);

                    if (db.SaveChanges() > 0)
                    {
                        return(newSetting);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
        }
Exemplo n.º 5
0
 public Result PostCountryCreate(COUNTRY country)
 {
     try
     {
         db = new BaseEntities();
         if (country.CountryId > 0)
         {
             //menu.is_active = menu.is_active;
             db.Entry(country).State = System.Data.Entity.EntityState.Modified;
             result.Message          = string.Format(BaseConst.MSG_SUCCESS_UPDATE, "Country");
         }
         else
         {
             db.COUNTRies.Add(country);
             result.Message = string.Format(BaseConst.MSG_SUCCESS_CREATE, "Country");
         }
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         result.MessageType = MessageType.Error;
         result.Message     = ex.Message;
     }
     return(result);
 }
Exemplo n.º 6
0
 public Result PostCreateEdit(user user, FormCollection frm)
 {
     try
     {
         string password = frm["userpassword"];
         db = new BaseEntities();
         if (user.user_id > 0)
         {
             var msg = db.USP_CreateUser(user.user_id, user.user_name, user.login_id, user.email_id, user.mobile, password, user.gender, user.user_photo, user.parent_user_id, user.role_bit, SessionUtil.GetCompanyID(), SessionUtil.GetUserID(), user.role_id, null, user.create_work_order_access_id, user.view_work_order_access_id, user.is_change_requester, user.is_service_provider, user.is_active).FirstOrDefault().MSG;
             result.Message = msg == "Success" ? string.Format(BaseConst.MSG_SUCCESS_CREATE, "User") : msg;
         }
         else
         {
             user.is_active = true;
             var msg = db.USP_CreateUser(user.user_id, user.user_name, user.login_id, user.email_id, user.mobile, password, user.gender, user.user_photo, user.parent_user_id, user.role_bit, SessionUtil.GetCompanyID(), SessionUtil.GetUserID(), user.role_id, null, user.create_work_order_access_id, user.view_work_order_access_id, user.is_change_requester, user.is_service_provider, user.is_active).FirstOrDefault().MSG;
             result.Message = msg == "Success" ? string.Format(BaseConst.MSG_SUCCESS_UPDATE, "User") : msg;
         }
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         result.MessageType = MessageType.Error;
         result.Message     = ex.Message;
     }
     return(result);
 }
Exemplo n.º 7
0
 public List <Settings> getAllUnUsedSettings()
 {
     using (var db = new BaseEntities())
     {
         return(db.Settings.Where(s => s.UserId == null).ToList());
     }
 }
 public AspNetUsers getUsersByUsersId(string userId)
 {
     using (var db = new BaseEntities())
     {
         return(db.AspNetUsers.FirstOrDefault(s => s.Id == userId));
     }
 }
Exemplo n.º 9
0
        public FunctionResult_Models GetEntriesCSV(Options_Models Options)
        {
            using (var db = new BaseEntities())
            {
                var FunctRes = new FunctionResult_Models(true);

                var Query = db.Schedules.Where(s => s.AppId == Options.AppId);

                //Filter Validity

                var query = Query.AsEnumerable();

                var Excludes = ScheduleExclusionFields.ToList();


                //Hide these 2
                Excludes.Add("SchedulesId");

                if (query.Count() == 0)
                {
                    return(new FunctionResult_Models(false)
                    {
                        message = "No Entries Found!"
                    });
                }

                FunctRes.DataHeaders = ExcludeHeaders(query.FirstOrDefault(), Excludes);

                FunctRes.DataAsDictionary = query.OrderByDescending(s => s.CreatedOn).ThenByDescending(s => s.AppId).Select(s =>
                                                                                                                            ExcludeHeaders(s.GetType().GetProperties().Where(p => p.GetMethod.IsVirtual == false).ToDictionary(prop => prop.Name, prop => prop.GetValue(s, null)), Excludes, true).
                                                                                                                            ToDictionary(prop => prop.Key, prop => prop.Value)).ToList();

                return(FunctRes);
            }
        }
Exemplo n.º 10
0
 public List <Settings> getAllSettings()
 {
     using (var db = new BaseEntities())
     {
         return(db.Settings.ToList());
     }
 }
Exemplo n.º 11
0
        public frmCashboxCheckout(BaseEntities db, WaybillList wb)
        {
            InitializeComponent();

            _db = db;
            _wb = wb;
        }
Exemplo n.º 12
0
        private void OkButton_Click(object sender, EventArgs e)
        {
            if (!is_registered)
            {
                Application.Exit();

                return;
            }

            using (var db = new BaseEntities())
            {
                var user = db.Users.FirstOrDefault(w => w.Name == UserIDEdit.Text && w.Pass == passtextEdit.Text);
                if (user != null)
                {
                    user.LastLogin = DBHelper.ServerDateTime();
                    user.IsOnline  = true;
                    db.SaveChanges();

                    this.Hide();
                    mainForm.main_form = new mainForm((int)UserIDEdit.EditValue);
                    mainForm.main_form.Show();
                }
                else
                {
                    label1.Visible = true;
                }
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// 恢复系统用户的账号状态
        /// </summary>
        /// <param name="EmployeeIds">员工基本信息表id</param>
        public void ResetSysUserState(string EmployeeIds, string NewCode)
        {
            if (string.IsNullOrWhiteSpace(EmployeeIds))
            {
                return;
            }
            HREntities entities = FormulaHelper.GetEntities <HREntities>();

            string[] UserArr = entities.Set <T_Employee>().Where(c => EmployeeIds.Contains(c.ID)).ToList().Select(t => t.UserID).ToArray();
            if (UserArr == null || UserArr.Length == 0)
            {
                return;
            }
            string       UserIds      = string.Join(",", UserArr);
            BaseEntities baseEntities = FormulaHelper.GetEntities <BaseEntities>();

            baseEntities.Set <S_A_User>().Where(t => UserIds.Contains(t.ID)).Update(t =>
            {
                t.DeleteTime = null;
                t.ModifyTime = DateTime.Now;
                t.IsDeleted  = "0";
                t.OutDate    = null;
                if (!string.IsNullOrEmpty(NewCode))
                {
                    t.Code   = NewCode;
                    t.WorkNo = NewCode;
                }
            });
            baseEntities.SaveChanges();
        }
Exemplo n.º 14
0
        /// <summary>
        /// 同步删除的人员到系统用户表
        /// </summary>
        /// <param name="EmployeeIds"></param>
        public void EmployeeDeleteToUser(string EmployeeIds)
        {
            HREntities entities = FormulaHelper.GetEntities <HREntities>();
            var        EList    = entities.Set <T_Employee>().Where(c => EmployeeIds.Contains(c.ID)).ToList();

            if (EList == null || EList.Count == 0)
            {
                return;
            }
            int          count        = 0;
            BaseEntities baseEntities = FormulaHelper.GetEntities <BaseEntities>();

            foreach (var employee in EList)
            {
                var user = baseEntities.Set <S_A_User>().Where(t => t.ID == employee.UserID).FirstOrDefault();
                if (user != null)
                {
                    count++;
                    user.DeleteTime = DateTime.Now;
                    user.ModifyTime = user.DeleteTime;
                    user.IsDeleted  = "1";

                    var retiredList = entities.Set <T_EmployeeRetired>().Where(c => c.EmployeeID == employee.ID).OrderBy("RetiredDate", false);
                    if (retiredList.Count() > 0)
                    {
                        user.OutDate = retiredList.FirstOrDefault().RetiredDate;
                    }
                }
            }
            if (count > 0)
            {
                baseEntities.SaveChanges();
            }
        }
Exemplo n.º 15
0
 public Settings getSettingsBySettingsId(int settingsId)
 {
     using (var db = new BaseEntities())
     {
         return(db.Settings.FirstOrDefault(s => s.SettingsID == settingsId));
     }
 }
        public List <User_ViewModel> getAllUsers()
        {
            using (var db = new BaseEntities())
            {
                var users = db.AspNetUsers.AsQueryable();
                List <User_ViewModel> list_user_viewModel = new List <User_ViewModel>();
                foreach (var item in users)
                {
                    var    setting = db.Settings.FirstOrDefault(s => s.UserId == item.Id);
                    string appId   = string.Empty;
                    if (setting != null)
                    {
                        appId = setting.AppId;
                    }

                    User_ViewModel user_viewModel = new User_ViewModel {
                        Email    = item.Email,
                        Id       = item.Id,
                        UserName = item.UserName,
                        AppId    = appId
                    };
                    list_user_viewModel.Add(user_viewModel);
                }


                return(list_user_viewModel);
            }
        }
Exemplo n.º 17
0
 public Settings getSettingsByAppId(string appId)
 {
     using (var db = new BaseEntities())
     {
         return(db.Settings.FirstOrDefault(s => s.AppId == appId));
     }
 }
Exemplo n.º 18
0
 /// <summary>
 /// 根据ID获取机构对象实体
 /// </summary>
 /// <param name="id">节点ID</param>
 /// <returns>SYS_Organization 节点对象</returns>
 private SYS_Organization GetOrg(Guid id)
 {
     using (var context = new BaseEntities())
     {
         return(context.SYS_Organization.SingleOrDefault(e => e.ID == id));
     }
 }
Exemplo n.º 19
0
 public Settings getSettingsByUserId(string userId)
 {
     using (var db = new BaseEntities())
     {
         return(db.Settings.FirstOrDefault(s => s.UserId == userId));
     }
 }
Exemplo n.º 20
0
        public static void WayBillReport(Guid id, BaseEntities db, string template_name)
        {
            var dataForReport = new Dictionary <string, IList>();

            var wb = db.v_WaybillList.Where(w => w.Id == id).AsNoTracking().ToList();

            if (wb.Any())
            {
                int wbill_id = wb.First().WbillId;

                dataForReport.Add("WayBillList", wb);
                dataForReport.Add("WayBillItems", db.GetWaybillDetIn(wbill_id).ToList().OrderBy(o => o.Num).ToList());
                dataForReport.Add("Commission", db.Commission.Where(w => w.WbillId == wbill_id).Select(s => new
                {
                    MainName   = s.Kagent.Name,
                    FirstName  = s.Kagent1.Name,
                    SecondName = s.Kagent2.Name,
                    ThirdName  = s.Kagent3.Name
                }).ToList());

                IHelper.Print(dataForReport, template_name);
            }
            else
            {
                MessageBox.Show("Документ відсутній!");
            }
        }
Exemplo n.º 21
0
 public List <Settings> getSettingsByDateTime(DateTime dt)
 {
     using (var db = new BaseEntities())
     {
         return(db.Settings.Where(s => s.Scheduletime == dt.TimeOfDay).ToList());
     }
 }
Exemplo n.º 22
0
        public static bool CheckOutDate(WaybillList wb, BaseEntities db, DateTime date)
        {
            bool r     = true;
            var  query = (from wbd in db.WaybillDet
                          from m in db.Materials
                          where wbd.WbillId == wb.WbillId && m.MatId == wbd.MatId
                          orderby wbd.OnDate descending
                          select new
            {
                wbd.OnDate,
                m.Name
            }
                          ).FirstOrDefault();

            /*
             *              select first 1 distinct wbd.ondate, m.name
             * from waybilldet wbd , materials m
             * where wbd.wbillid=:WBILLID and m.matid = wbd.matid
             * order by wbd.ondate desc
             */
            if (query != null && date < query.OnDate)
            {
                if (MessageBox.Show("Дата документа не може бути меншою за дату видаткової партії! \nПозиція: " + query.Name + " \nДата: " + query.OnDate.ToString() + " \nЗмінити дату докомента на " + query.OnDate.ToString() + "?", "Зміна дати докуманта", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    wb.OnDate = query.OnDate.Value;
                    db.SaveChanges();
                }
                else
                {
                    r = false;
                }
            }

            return(r);
        }
Exemplo n.º 23
0
        /// <summary>
        /// 根据传入参数获取编码方案预览
        /// </summary>
        /// <param name="name">编码方案名称</param>
        /// <param name="id">业务记录ID</param>
        /// <param name="mark">标识符</param>
        /// <returns>JsonResult</returns>
        public JsonResult GetCode(string name, string id, string mark)
        {
            var verify = new SessionVerify();

            if (!verify.Compare())
            {
                return(verify.Result);
            }

            Guid oid;

            if (!Guid.TryParse(id, out oid))
            {
                return(verify.Result.InvalidGuid());
            }

            var session = verify.Session;

            using (var context = new BaseEntities())
            {
                var scheme = context.SYS_Code_Scheme.SingleOrDefault(s => s.Name == name);
                if (scheme == null)
                {
                    General.LogToLogServer("001101", $"不存在名称为:【{name}】的编码方案", "编码规则", "生成编码");
                    return(verify.Result.ServiceUnavailable());
                }

                var code = GetCode(scheme.ID, null, session.UserId, oid, null, mark);
                return(code == null?verify.Result.DataBaseError() : verify.Result.Success(code.ToString()));
            }
        }
Exemplo n.º 24
0
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            /*
             * MatComboBox.EditValue = IHelper.ShowDirectList(MatComboBox.EditValue, 5);
             * _wbd.MatId = MatComboBox.EditValue != null && MatComboBox.EditValue != DBNull.Value ? (int)MatComboBox.EditValue : _wbd.MatId;*/

            using (var f = new frmWhCatalog(1))
            {
                f.uc.whKagentList.Enabled = false;
                f.uc.OnDateEdit.Enabled   = false;
                f.uc.bar3.Visible         = false;
                f.uc.ByWhBtn.Down         = true;
                f.uc.splitContainerControl1.SplitterPosition = 0;
                using (var db = new BaseEntities())
                {
                    f.uc.WHTreeList.DataSource = db.GetWhTree(DBHelper.CurrentUser.UserId, 2).Where(w => w.GType == 1 && w.Num == _wbd.WId).ToList();
                }
                f.uc.GrpNameGridColumn.GroupIndex = 0;

                f.uc.isDirectList = true;
                if (f.ShowDialog() == DialogResult.OK)
                {
                    _wbd.MatId            = f.uc.focused_wh_mat.MatId;
                    MatComboBox.EditValue = _wbd.MatId;
                    SetValue();
                }
            }
        }
 public List <Schedules> getAllUpcomingSchedulesByAppId(string appId)
 {
     using (var db = new BaseEntities())
     {
         return(db.Schedules.Where(s => !s.IsSent && s.AppId == appId && s.IsValid).ToList());
     }
 }
Exemplo n.º 26
0
        private void ExecuteItemBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (focused_tree_node == null)
            {
                return;
            }

            switch (focused_tree_node.GType)
            {
            case 2:
                var pd_row = MoneyMoveGridView.GetFocusedRow() as MoneyMoveList_Result;
                using (var db = new BaseEntities())
                {
                    var pd = db.PayDoc.Find(pd_row.PayDocId);
                    pd.Checked = pd_row.Checked == 0 ? 1 : 0;

                    var pd_to = db.PayDoc.FirstOrDefault(w => w.OperId == pd.OperId);
                    if (pd_to != null)
                    {
                        pd_to.Checked = pd.Checked;
                    }

                    db.SaveChanges();
                }
                break;
            }

            RefrechItemBtn.PerformClick();
        }
 public List <Schedules> getSchedulesByAppId(string appId)
 {
     using (var db = new BaseEntities())
     {
         return(db.Schedules.Where(s => s.AppId == appId).ToList());
     }
 }
 public Schedules getScheduleBySchedulesId(int schedulesId)
 {
     using (var db = new BaseEntities())
     {
         return(db.Schedules.FirstOrDefault(s => s.SchedulesId == schedulesId));
     }
 }
Exemplo n.º 29
0
 /// <summary>
 /// 根据ID获取用户组对象实体
 /// </summary>
 /// <param name="id">用户组ID</param>
 /// <returns>SYS_UserGroup 用户组对象</returns>
 private SYS_UserGroup GetGroup(Guid id)
 {
     using (var context = new BaseEntities())
     {
         return(context.SYS_UserGroup.SingleOrDefault(e => e.ID == id));
     }
 }
Exemplo n.º 30
0
 /// <summary>
 /// 根据用户ID获取用户对象实体
 /// </summary>
 /// <param name="id">用户ID</param>
 /// <returns>SYS_User 用户对象实体</returns>
 private SYS_User GetUser(Guid id)
 {
     using (var context = new BaseEntities())
     {
         return(context.SYS_User.SingleOrDefault(u => u.ID == id));
     }
 }
Exemplo n.º 31
0
 public BaseEntities Get()
 {
     return dataContext ?? (dataContext = new BaseEntities());
 }