Exemplo n.º 1
0
        public string AddCustomer(FormCollection collection, Customer c)
        {
            Message = null;
            AMSEntities ae = new AMSEntities();
            string uname = collection.Get("UserName");
            string pwd = collection.Get("Password");
            string repwd = collection.Get("ReTypePassword");
            if (pwd == repwd)
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    WebSecurity.CreateUserAndAccount(uname, pwd);
                    Roles.AddUserToRole(uname, "Customer");
                    c.MembershipUserID = WebSecurity.GetUserId(uname);
                    c.CustStatus = true;

                    DataStore.Create(c);
                    DataStore.SaveChanges();
                    Emailer.Send(c.CustEmail, "Registration confirmed", "Welcome to AMS");
                    ts.Complete();
                };
                Message = "Successfully Registered";

                return Message;
            }
            else
            {
                return Message;
            }
        }
Exemplo n.º 2
0
 private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex > -1 && e.RowIndex > -1)
     {
         if (dataGridView1.SelectedRows.Count > 0)
         {
             vwAss        ass1 = dataGridView1.SelectedRows[0].DataBoundItem as vwAss;
             tbAssociator ass  = null;
             using (AMSEntities amsContext = new AMSEntities())
             {
                 ass = amsContext.tbAssociator.FirstOrDefault(a => a.iAssID == ass1.iAssID);
             }
             frmAss frmass = new frmAss();
             frmass.ass         = ass;
             frmass.OperType    = "DETAIL";
             frmass.MinimizeBox = false;
             frmass.MaximizeBox = false;
             frmass.ShowDialog();
         }
         else
         {
             Helper.ShowInfo(this, "请查询或搜索会员,并选择会员");
         }
     }
 }
Exemplo n.º 3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtLimitCode.Text == "" || txtLimitName.Text == "")
                {
                    throw new Exception("角色代码和名称都不能为空");
                }
                if (!txtLimitCode.Text.StartsWith("OP"))
                {
                    throw new Exception("角色代码需以OP开头");
                }

                using (AMSEntities amsContext = new AMSEntities())
                {
                    int i = amsContext.tbLimit.Count(l => l.vcLimitCode == txtLimitCode.Text || l.vcLimitName == txtLimitName.Text);
                    if (i > 0)
                    {
                        throw new Exception("相同角色代码或名称的角色已存在");
                    }
                    tbLimit limit = new tbLimit();
                    limit.vcLimitCode = txtLimitCode.Text;
                    limit.vcLimitName = txtLimitName.Text;
                    amsContext.AddTotbLimit(limit);
                    amsContext.SaveChanges();
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                ErrorLog.Write(this, ex);
            }
        }
Exemplo n.º 4
0
 private void btnAddCard_Click(object sender, EventArgs e)
 {
     try
     {
         if (dataGridView1.SelectedRows.Count > 0)
         {
             vwAss ass1 = dataGridView1.SelectedRows[0].DataBoundItem as vwAss;
             if (ass1.vcAssState == "1")
             {
                 throw new Exception("此会员已发卡,请重新查询或搜索会员");
             }
             //vwAss ass1 = dataGridView1.SelectedRows[0].DataBoundItem as vwAss;
             tbAssociator ass = null;
             using (AMSEntities amsContext = new AMSEntities())
             {
                 ass = amsContext.tbAssociator.FirstOrDefault(a => a.iAssID == ass1.iAssID);
             }
             frmAddCard addcard = new frmAddCard();
             addcard.ass         = ass;
             addcard.MinimizeBox = false;
             addcard.MaximizeBox = false;
             addcard.ShowDialog();
         }
         else
         {
             Helper.ShowInfo(this, "请查询或搜索会员,并选择会员");
         }
     }
     catch (Exception ex)
     {
         ErrorLog.Write(this, ex);
     }
 }
Exemplo n.º 5
0
        public string AddCustomer(FormCollection collection, Customer c)
        {
            Message = null;
            AMSEntities ae    = new AMSEntities();
            string      uname = collection.Get("UserName");
            string      pwd   = collection.Get("Password");
            string      repwd = collection.Get("ReTypePassword");

            if (pwd == repwd)
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    WebSecurity.CreateUserAndAccount(uname, pwd);
                    Roles.AddUserToRole(uname, "Customer");
                    c.MembershipUserID = WebSecurity.GetUserId(uname);
                    c.CustStatus       = true;

                    DataStore.Create(c);
                    DataStore.SaveChanges();
                    Emailer.Send(c.CustEmail, "Registration confirmed", "Welcome to AMS");
                    ts.Complete();
                };
                Message = "Successfully Registered";

                return(Message);
            }
            else
            {
                return(Message);
            }
        }
Exemplo n.º 6
0
 private void cmbIgEXGoods_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         if (cmbIgEXGoods.Items.Count > 0)
         {
             using (AMSEntities amsContext = new AMSEntities())
             {
                 string     strGoodsCode = cmbIgEXGoods.SelectedValue.ToString();
                 tbCommCode IgExGoods1   = amsContext.tbCommCode.FirstOrDefault(cc => cc.vcCommSign == "EX" && cc.vcCommCode == strGoodsCode);
                 if (IgExGoods1 == null)
                 {
                     txtIgExCost.Text = "";
                     throw new Exception("获取积分兑换项目异常,请检查积分兑换项目的参数配置是否正确!");
                 }
                 else
                 {
                     txtIgExCost.Text = IgExGoods1.vcComments;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         ErrorLog.Write(this, ex, "刷新异常");
     }
 }
Exemplo n.º 7
0
 public static void Save(AMSEntities amsContext)
 {
     try
     {
         amsContext.SaveChanges();
     }
     catch (OptimisticConcurrencyException)
     {
         throw new Exception("并发冲突,请重载数据");
     }
     catch (UpdateException uex)
     {
         if (uex.InnerException == null)
         {
             throw new Exception("更新错误:" + uex.Message);
         }
         else
         {
             throw new Exception("更新错误:" + uex.InnerException.Message);
         }
     }
     catch (Exception ex)
     {
         ErrorLog.Write(ex);
         throw ex;
     }
 }
Exemplo n.º 8
0
        private void btnQuery_Click(object sender, EventArgs e)
        {
            try
            {
                string   strOper = cmbOper.SelectedValue.ToString();
                DateTime dtBegin = new DateTime(dtpBegin.Value.Year, dtpBegin.Value.Month, dtpBegin.Value.Day, 0, 0, 0);
                DateTime dtEnd   = new DateTime(dtpEnd.Value.Year, dtpEnd.Value.Month, dtpEnd.Value.Day, 23, 59, 59);
                using (AMSEntities amsContext = new AMSEntities())
                {
                    var queryresult = from a in amsContext.tbBusiLog join b in amsContext.tbCommCode on a.vcOperType equals b.vcCommCode where b.vcCommSign == "OT" && a.dtOperDate >= dtBegin && a.dtOperDate <= dtEnd select new { a.iSerial, a.vcAssName, a.vcAssCardID, a.vcLinkSerial, b.vcCommName, a.vcOperID, a.vcOperName, a.dtOperDate };
                    if (strOper != "全部")
                    {
                        queryresult = queryresult.Where(a => a.vcOperID == strOper);
                    }
                    queryresult = queryresult.OrderBy(a => a.iSerial);

                    dgvResult.DataSource = queryresult;
                    dgvResult.Columns["iSerial"].HeaderText      = "操作流水";
                    dgvResult.Columns["vcAssName"].HeaderText    = "会员姓名";
                    dgvResult.Columns["vcAssCardID"].HeaderText  = "会员卡号";
                    dgvResult.Columns["vcLinkSerial"].HeaderText = "相关流水";
                    dgvResult.Columns["vcCommName"].HeaderText   = "操作类型";
                    dgvResult.Columns["vcOperID"].HeaderText     = "操作员ID";
                    dgvResult.Columns["vcOperName"].HeaderText   = "操作员";
                    dgvResult.Columns["dtOperDate"].HeaderText   = "操作日期";
                }
            }
            catch (Exception ex)
            {
                ErrorLog.Write(this, ex, "查询异常");
            }
        }
        // load payment details under a selected payee
        private void RetrievePayment(object sender, EventArgs e)
        {
            // get selected payee
            string payeeId = this.view.SelectedPayeeId;
            //Payee payee = this.view.SelectedPayee;

            // load payment details
            List <PaymentDetail> payments = new List <PaymentDetail>();

            using (var db = new AMSEntities())
            {
                var result = from payee in db.Payees
                             from payment in db.Payments
                             where payee.Payments.Contains(payment) &&
                             payment.PayeeID == payeeId &&
                             payment.ClientID == this.view.AccessId
                             select new PaymentDetail {
                    PayeeName = payee.Name, AccountNumber = payment.AccountNumber, Amount = (double)payment.Amount, BillingDate = payment.BillingDate, PaymentDate = payment.PaymentDate
                };
                foreach (var item in result)
                {
                    payments.Add(item);
                }
            }
            this.view.PaymentDetails = payments;
        }
Exemplo n.º 10
0
        private void SetRole(AMSEntities amsContext)
        {
            IOrderedQueryable <tbLimit> limit = amsContext.tbLimit.OrderBy(l => l.vcLimitCode);

            treeView1.BeginUpdate();
            treeView1.Nodes.Clear();
            TreeNode tnRole = new TreeNode();

            tnRole.Name             = "limit";
            tnRole.Text             = "角色";
            tnRole.ImageIndex       = 0;
            tnRole.ContextMenuStrip = this.contextMenuStrip1;
            foreach (tbLimit li in limit)
            {
                TreeNode tn = new TreeNode();
                tn.Name             = li.vcLimitCode;
                tn.Text             = li.vcLimitName;
                tn.ImageIndex       = -1;
                tn.ContextMenuStrip = this.contextMenuStrip2;
                tnRole.Nodes.Add(tn);
            }
            treeView1.Nodes.Add(tnRole);
            treeView1.EndUpdate();
            treeView1.ExpandAll();
        }
Exemplo n.º 11
0
        private void btnCancel_Click(object sender, EventArgs e)
        {
            string strType = btnAdd.Text;

            switch (strType)
            {
            case "添加":
                txtOperID.Text         = "";
                txtOperID.Enabled      = true;
                txtOperName.Text       = "";
                txtOperPwd.Text        = "";
                txtOperPwdConfirm.Text = "";
                break;

            case "修改":
                using (AMSEntities amsContext = new AMSEntities())
                {
                    tbOper oper = amsContext.tbOper.FirstOrDefault(o => o.vcOperID == txtOperID.Text);
                    //txtOperID.Text = oper.vcOperID;
                    //txtOperID.Enabled = false;
                    txtOperName.Text       = oper.vcOperName;
                    txtOperPwd.Text        = oper.vcOperPwd;
                    txtOperPwdConfirm.Text = oper.vcOperPwd;
                    cmbRole.SelectedValue  = oper.vcLimit;
                }
                break;
            }
        }
Exemplo n.º 12
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtOperID.Text.Equals("admin"))
         {
             throw new Exception("系统管理员帐户不能注销");
         }
         DialogResult dr = MessageBox.Show(this, "是否注销\"" + txtOperName.Text + "\"操作员", "注销操作员", MessageBoxButtons.YesNo);
         if (dr == DialogResult.Yes)
         {
             using (AMSEntities amsContext = new AMSEntities())
             {
                 tbOper oper = amsContext.tbOper.FirstOrDefault(o => o.vcOperID == txtOperID.Text);
                 //oper.vcLimit = cmbRole.SelectedValue.ToString();
                 //oper.vcOperName = txtOperName.Text;
                 //oper.vcOperPwd = txtOperPwd.Text;
                 //oper.vcOperLevel = cmbOperLevel.SelectedValue.ToString();
                 oper.iFlag     = 1;
                 oper.dtExpDate = DateTime.Now;
                 amsContext.SaveChanges();
                 MessageBox.Show(this, "操作员注销成功", "注销操作员");
             }
             //frmOper_Load(null, null);
         }
     }
     catch (Exception ex)
     {
         ErrorLog.Write(this, ex, "操作员");
     }
 }
Exemplo n.º 13
0
        void MyReload_Click6(object sender, EventArgs e)
        {
            amsContext = new AMSEntities();
            var al = GetAL();

            this.usParaSet6.MyAMSEntities = amsContext;
            this.usParaSet6.MyDataSource  = al;
            Helper.ShowInfo(this, "数据已重新加载");
        }
Exemplo n.º 14
0
        void MyReload_Click(object sender, EventArgs e)
        {
            amsContext = new AMSEntities();
            var goods = GetGoods();//from item in amsContext.tbGoods orderby item.vcGoodsCode select item;

            this.usParaSet1.MyAMSEntities = amsContext;
            this.usParaSet1.MyDataSource  = goods;
            Helper.ShowInfo(this, "数据已重新加载");
        }
Exemplo n.º 15
0
        void MyReload_Click5(object sender, EventArgs e)
        {
            amsContext = new AMSEntities();
            var operLevel = GetOperLevel();

            this.usParaSet5.MyAMSEntities = amsContext;
            this.usParaSet5.MyDataSource  = operLevel;
            Helper.ShowInfo(this, "数据已重新加载");
        }
Exemplo n.º 16
0
        void MyReload_Click4(object sender, EventArgs e)
        {
            amsContext = new AMSEntities();
            var CommCode = GetCommCode();

            this.usParaSet4.MyAMSEntities = amsContext;
            this.usParaSet4.MyDataSource  = CommCode;
            Helper.ShowInfo(this, "数据已重新加载");
        }
Exemplo n.º 17
0
        void MyReload_Click3(object sender, EventArgs e)
        {
            amsContext = new AMSEntities();
            var fillProm = GetFillProm();

            this.usParaSet3.MyAMSEntities = amsContext;
            this.usParaSet3.MyDataSource  = fillProm;
            Helper.ShowInfo(this, "数据已重新加载");
        }
Exemplo n.º 18
0
        void MyReload_Click2(object sender, EventArgs e)
        {
            amsContext = new AMSEntities();
            var goodsRate = GetGoodsRate();

            this.usParaSet2.MyAMSEntities = amsContext;
            this.usParaSet2.MyDataSource  = goodsRate;
            Helper.ShowInfo(this, "数据已重新加载");
        }
Exemplo n.º 19
0
 public ActionResult Index()
 {
     message = "";
     AMSEntities ae = new AMSEntities();
     User uu = ae.Users.Where(e => e.MembershipUserID == WebSecurity.CurrentUserId).Single();
     List<User> users = ae.Users.Where(e => e.CompanyID==uu.CompanyID).ToList();
     //ViewBag["Message"] = message;
     return View(users);
 }
Exemplo n.º 20
0
        public EFRepository()
        {
            dbContext = new AMSEntities();

            //SERIALIZE WILL FAIL WITH PROXIED ENTITIES
            dbContext.Configuration.ProxyCreationEnabled = false;

            //ENABLING COULD CAUSE ENDLESS LOOPS AND PERFORMANCE PROBLEMS
            dbContext.Configuration.LazyLoadingEnabled = false;
        }
Exemplo n.º 21
0
        public ActionResult Index()
        {
            message = "";
            AMSEntities ae    = new AMSEntities();
            User        uu    = ae.Users.Where(e => e.MembershipUserID == WebSecurity.CurrentUserId).Single();
            List <User> users = ae.Users.Where(e => e.CompanyID == uu.CompanyID).ToList();

            //ViewBag["Message"] = message;
            return(View(users));
        }
Exemplo n.º 22
0
        private void FillGridView()
        {
            DataTable table = new DataTable();

            /* Fill table with Company information */
            string connectionString = ConfigurationManager.ConnectionStrings["AMSConnectionString"].ConnectionString;

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                string sql = "SELECT CompanyID, CompanyName, CompanyAddress, CompanyPhone FROM Company ORDER BY CompanyID";
                using (SqlCommand cmd = new SqlCommand(sql, conn))
                {
                    using (SqlDataAdapter ad = new SqlDataAdapter(cmd))
                    {
                        ad.Fill(table);
                    }
                }
            }
            /* Adding URL column for Add User Admin to the table */
            table.Columns.Add("UserAdmins", typeof(String));
            table.Columns.Add("AddUserAdmin", typeof(String));

            foreach (DataRow dr in table.Rows)
            {
                /* "User Admins" */
                //get a list of administrator names which are in company id=x
                int         companyID = Convert.ToInt32(dr["CompanyID"]);
                AMSEntities ae        = new AMSEntities();;
                /* Users: list of users in a particular company */
                List <User> users = ae.CreateObjectSet <User>().Where <User>(e => e.CompanyID == companyID).AsQueryable <User>().ToList <User>();

                string usernameList = "";
                foreach (User user in users)
                {
                    int userID = user.MembershipUserID;
                    /* UserProfiles: list of UserProfiles in a particular company */
                    List <UserProfile> userProfiles = ae.CreateObjectSet <UserProfile>().Where <UserProfile>(e => e.UserId == userID).AsQueryable <UserProfile>().ToList <UserProfile>();
                    foreach (UserProfile userProfile in userProfiles)
                    {
                        int    userProfileID = userProfile.UserId;
                        string username      = userProfile.UserName;
                        if (Roles.IsUserInRole(username, "User Admin"))
                        {
                            usernameList += username + " ";
                        }
                    }
                }
                dr["UserAdmins"] = usernameList;
                /* "Add User Admins" */
                dr["AddUserAdmin"] = companyID;
            }

            GridViewCompanies.DataSource = table;
            GridViewCompanies.DataBind();
        }
Exemplo n.º 23
0
 private void btnCardLose_Click(object sender, EventArgs e)
 {
     try
     {
         if (dataGridView1.SelectedRows.Count > 0)
         {
             vwAssCard        ass1    = dataGridView1.SelectedRows[0].DataBoundItem as vwAssCard;
             tbAssociator     ass     = null;
             tbAssociatorCard assCard = null;
             tbIntegral       ig      = null;
             using (AMSEntities amsContext = new AMSEntities())
             {
                 //数据操作
                 ass     = amsContext.tbAssociator.FirstOrDefault(a => a.iAssID == ass1.iAssID);
                 assCard = amsContext.tbAssociatorCard.FirstOrDefault(a => a.iAssID == ass1.iAssID && a.vcAssCardID == ass1.vcAssCardID);
                 ig      = amsContext.tbIntegral.FirstOrDefault(i => i.iAssID == ass1.iAssID && i.vcAssCardID == ass1.vcAssCardID);
             }
             if (ass == null)
             {
                 throw new Exception("未找到会员信息");
             }
             if (assCard == null)
             {
                 throw new Exception("未找到会员卡信息");
             }
             if (assCard.cCardState != ConstApp.CST_1)
             {
                 throw new Exception("此会员卡无法做挂失操作");
             }
             if (ass.vcAssState != ConstApp.AST_1)
             {
                 throw new Exception("此会员无法做挂失操作");
             }
             if (ig == null)
             {
                 throw new Exception("获取会员积分信息错误无法做挂失");
             }
             frmCardLose cardLose = new frmCardLose();
             cardLose.ass        = ass;
             cardLose.assCard    = assCard;
             cardLose.ig         = ig;
             cardLose.ControlBox = false;
             cardLose.ShowDialog();
         }
         else
         {
             Helper.ShowInfo(this, "请查询或搜索会员,并选择会员");
         }
     }
     catch (Exception ex)
     {
         ErrorLog.Write(this, ex);
     }
 }
Exemplo n.º 24
0
        private void FillGridView()
        {
            DataTable table = new DataTable();

            /* Fill table with Company information */
            string connectionString = ConfigurationManager.ConnectionStrings["AMSConnectionString"].ConnectionString;
            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                string sql = "SELECT CompanyID, CompanyName, CompanyAddress, CompanyPhone FROM Company ORDER BY CompanyID";
                using (SqlCommand cmd = new SqlCommand(sql, conn))
                {
                    using (SqlDataAdapter ad = new SqlDataAdapter(cmd))
                    {
                        ad.Fill(table);
                    }
                }
            }
            /* Adding URL column for Add User Admin to the table */
            table.Columns.Add("UserAdmins"  , typeof(String));
            table.Columns.Add("AddUserAdmin", typeof(String));

            foreach (DataRow dr in table.Rows)
            {
                /* "User Admins" */
                //get a list of administrator names which are in company id=x
                int companyID = Convert.ToInt32( dr["CompanyID"] );
                AMSEntities ae = new AMSEntities();;
                /* Users: list of users in a particular company */
                List<User> users = ae.CreateObjectSet<User>().Where<User>(e => e.CompanyID == companyID).AsQueryable<User>().ToList<User>();

                string usernameList = "";
                foreach (User user in users)
                {
                    int userID = user.MembershipUserID;
                    /* UserProfiles: list of UserProfiles in a particular company */
                    List<UserProfile> userProfiles = ae.CreateObjectSet<UserProfile>().Where<UserProfile>(e => e.UserId == userID).AsQueryable<UserProfile>().ToList<UserProfile>();
                    foreach (UserProfile userProfile in userProfiles)
                    {
                        int userProfileID = userProfile.UserId;
                        string username = userProfile.UserName;
                        if(Roles.IsUserInRole(username, "User Admin")){
                            usernameList += username + " ";
                        }
                    }

                }
                dr["UserAdmins"] = usernameList;
                /* "Add User Admins" */
                dr["AddUserAdmin"] = companyID;
            }

            GridViewCompanies.DataSource = table;
            GridViewCompanies.DataBind();
        }
Exemplo n.º 25
0
 private void frmParaSet_Load(object sender, EventArgs e)
 {
     try
     {
         amsContext = new AMSEntities();
         BindGoods();
     }
     catch (Exception ex)
     {
         ErrorLog.Write(this, ex);
     }
 }
Exemplo n.º 26
0
        private void btnQuery_Click(object sender, EventArgs e)
        {
            try
            {
                string strCardID  = txtCardID.Text.Trim();
                string strAssName = txtAssName.Text.Trim();
                string strBeginIg = txtBeginIg.Text.Trim();
                string strEndIg   = txtEndIg.Text.Trim();
                int    beginIg    = 0;
                int    endIg      = 0;
                if (chbIg.Checked)
                {
                    if (strBeginIg == "" || strEndIg == "")
                    {
                        throw new Exception("请填写正确的积分段值!");
                    }
                    else
                    {
                        beginIg = int.Parse(strBeginIg);
                        endIg   = int.Parse(strEndIg);
                    }
                }
                using (AMSEntities amsContext = new AMSEntities())
                {
                    var queryresult = from a in amsContext.tbIntegral join b in amsContext.tbAssociator on a.iAssID equals b.iAssID select new { b.vcAssName, a.vcAssCardID, a.nBalance, a.iIgValue, b.vcLinkPhone };
                    if (strCardID != "")
                    {
                        queryresult = queryresult.Where(a => a.vcAssCardID == strCardID);
                    }
                    if (strAssName != "")
                    {
                        queryresult = queryresult.Where(a => a.vcAssName.StartsWith(strAssName) || a.vcAssName.EndsWith(strAssName));
                    }
                    if (chbIg.Checked)
                    {
                        queryresult = queryresult.Where(a => a.iIgValue >= beginIg && a.iIgValue <= endIg);
                    }

                    queryresult = queryresult.OrderBy(a => a.vcAssCardID);

                    dgvCurIG.DataSource = queryresult;
                    dgvCurIG.Columns["vcAssName"].HeaderText   = "会员姓名";
                    dgvCurIG.Columns["vcAssCardID"].HeaderText = "会员卡号";
                    dgvCurIG.Columns["nBalance"].HeaderText    = "当前余额";
                    dgvCurIG.Columns["iIgValue"].HeaderText    = "当前积分";
                    dgvCurIG.Columns["vcLinkPhone"].HeaderText = "联系电话";
                }
            }
            catch (Exception ex)
            {
                ErrorLog.Write(this, ex, "查询异常");
            }
        }
Exemplo n.º 27
0
        public GlobalParams(AMSEntities amsContext)
        {
            CommCode = (from cc in amsContext.tbCommCode orderby cc.vcCommSign, cc.vcCommCode select cc).ToList <tbCommCode>();
            Goods    = (from gs in amsContext.tbGoods orderby gs.vcGoodsCode select gs).ToList <tbGoods>();
            Opers    = (from o in amsContext.tbOper orderby o.vcLimit, o.vcOperName select o).ToList <tbOper>();//where o.iFlag==0
            Limit    = (from l in amsContext.tbLimit orderby l.vcLimitCode select l).ToList <tbLimit>();

            GoodsRate = (from gr in amsContext.tbGoodsRate orderby gr.vcGoodsCode, gr.vcAssLevel select gr).ToList <tbGoodsRate>();
            FillProm  = (from fp in amsContext.tbFillProm orderby fp.iFloor select fp).ToList <tbFillProm>();
            OperLimit = (from ol in amsContext.tbOperLimit orderby ol.vcLimitCode, ol.vcMenu1, ol.vcMenu2 select ol).ToList <tbOperLimit>();
            OperLevel = (from ol in amsContext.tbOperLevel orderby ol.vcOperLevel select ol).ToList <tbOperLevel>();
        }
Exemplo n.º 28
0
        private void btnReadCard_Click(object sender, EventArgs e)
        {
            int ret = 0;

            try
            {
                //读取会员卡卡号
                //开始卡操作----------------------------------
                string strCardNo = "";
                ret = Helper.ReadCard(ref strCardNo);
                if (ret != 0)
                {
                    throw new Exception("卡操作异常");
                }
                txtAssCardID.Text = strCardNo;

                //txtAssCardID.Text = "00105";

                if (string.IsNullOrEmpty(txtAssCardID.Text))
                {
                    throw new Exception("请首先读取会员卡卡号");
                }

                using (AMSEntities amsContext = new AMSEntities())
                {
                    //数据操作
                    assCard = amsContext.tbAssociatorCard.FirstOrDefault(ac => ac.vcAssCardID == txtAssCardID.Text);
                    if (assCard == null)
                    {
                        throw new Exception("无此会员卡");
                    }
                    if (assCard.cCardState != "1")
                    {
                        throw new Exception("此会员不在正常使用状态,不能修改密码!");
                    }
                    ass = amsContext.tbAssociator.FirstOrDefault(a => a.iAssID == assCard.iAssID);
                    if (ass == null)
                    {
                        throw new Exception("此会员卡无会员在使用");
                    }
                }
                //其它操作
                btnOK.Enabled     = true;
                btnDetail.Enabled = true;
            }
            catch (Exception ex)
            {
                //异常操作
                ErrorLog.Write(this, ex);
                Helper.ShowError(this, Helper.PutCardError(ret));
            }
        }
Exemplo n.º 29
0
        private void btnReadCard_Click(object sender, EventArgs e)
        {
            int ret = 0;

            try
            {
                //从设备读取卡号信息
                //开始卡操作----------------------------------
                string strCardNo = "";
                ret = Helper.ReadCard(ref strCardNo);
                if (ret != 0)
                {
                    throw new Exception("卡操作异常");
                }
                //strCardNo = "00106";
                txtAssCardID.Text = strCardNo;
                if (string.IsNullOrEmpty(txtAssCardID.Text))
                {
                    throw new Exception("请读取卡号");
                }

                using (AMSEntities amsContext = new AMSEntities())
                {
                    //数据操作
                    assCard = amsContext.tbAssociatorCard.FirstOrDefault(a => a.vcAssCardID == txtAssCardID.Text && a.cCardState == "1");
                    if (assCard == null)
                    {
                        throw new Exception("该会员卡信息不存在,或不在正常使用状态,请重试!");
                    }
                    ass = amsContext.tbAssociator.FirstOrDefault(a => a.iAssID == assCard.iAssID);
                    if (ass == null)
                    {
                        throw new Exception("该会员卡的会员资料不存在,请检查!");
                    }
                    ig = amsContext.tbIntegral.FirstOrDefault(i => i.iAssID == assCard.iAssID && i.vcAssCardID == assCard.vcAssCardID);
                    if (ig == null)
                    {
                        throw new Exception("获取会员卡积分错误,请重试!");
                    }
                }
                //txtAssCardID.Text = assCard.vcAssCardID;
                txtAssName.Text = ass.vcAssName;
                txtBalance.Text = ig.nBalance.ToString();
                txtFillFee.Focus();
            }
            catch (Exception ex)
            {
                ErrorLog.Write(this, ex);
                Helper.ShowError(this, Helper.PutCardError(ret));
            }
        }
Exemplo n.º 30
0
 public void InitParams()
 {
     try
     {
         using (AMSEntities amsContext = new AMSEntities())
         {
             GlobalParams gp = new GlobalParams(amsContext);
         }
     }
     catch (Exception ex)
     {
         ErrorLog.Write(this, ex);
     }
 }
Exemplo n.º 31
0
        protected void submit_Click(object sender, EventArgs e)
        {
            AMSEntities ae = new AMSEntities();
            Company company = new Company();
            company.CompanyName = this.cName.Text;
            company.CompanyAddress = this.cAddress.Text;
            company.CompanyPhone = this.cPhone.Text;
            company.CompanyStatus = true;
            ae.Companies.AddObject(company);
            ae.SaveChanges();

            string url = "CreateUserAdmin.aspx" + "?companyID=" + company.CompanyID;
            Server.Transfer(url, true);
        }
        private void LoadCurrentUser(object sender, EventArgs e)
        {
            // get logged user id
            string accessId = this.view.AccessId;

            // load user info
            using (var db = new AMSEntities())
            {
                var result = from client in db.Clients
                             where client.AccessID == accessId
                             select client.Firstname + " " + client.Lastname;
                this.view.LoggedUserName = result.FirstOrDefault();
            }
        }
Exemplo n.º 33
0
 private void frmPrivilege_Load(object sender, EventArgs e)
 {
     using (AMSEntities amsContext = new AMSEntities())
     {
         try
         {
             SetFunc();
             SetRole(amsContext);
         }
         catch (Exception ex)
         {
             ErrorLog.Write(this, ex, "数据初始化出错");
         }
     }
 }
Exemplo n.º 34
0
        private void btnQuery_Click(object sender, EventArgs e)
        {
            try
            {
                string strCardID  = txtCardID.Text.Trim();
                string strAssName = txtAssName.Text.Trim();
                long   BillNo     = 0;
                if (txtBillNo.Text.Trim() != "")
                {
                    BillNo = long.Parse(txtBillNo.Text.Trim());
                }
                DateTime dtBegin = new DateTime(dtpBegin.Value.Year, dtpBegin.Value.Month, dtpBegin.Value.Day, 0, 0, 0);
                DateTime dtEnd   = new DateTime(dtpEnd.Value.Year, dtpEnd.Value.Month, dtpEnd.Value.Day, 23, 59, 59);
                using (AMSEntities amsContext = new AMSEntities())
                {
                    var queryresult = from a in amsContext.tbBillInvoice join b in amsContext.tbCommCode on a.vcBillType equals b.vcCommCode where a.dtCreateDate >= dtBegin && a.dtCreateDate <= dtEnd && a.vcEffFlag == "1" && b.vcCommSign == "BIT" select new { a.iBillNo, a.vcAssName, a.vcAssCardID, a.dtCreateDate, a.dtPrintDate, a.vcOperName, a.dTotalFee, a.vcPrintFlag, b.vcCommName };
                    if (strCardID != "")
                    {
                        queryresult = queryresult.Where(a => a.vcAssCardID == strCardID);
                    }
                    if (strAssName != "")
                    {
                        queryresult = queryresult.Where(a => a.vcAssName.StartsWith(strAssName) || a.vcAssName.EndsWith(strAssName));
                    }
                    if (BillNo > 0)
                    {
                        queryresult = queryresult.Where(a => a.iBillNo == BillNo);
                    }

                    queryresult = queryresult.OrderBy(a => a.vcAssCardID).ThenBy(a => a.iBillNo);

                    dgvResult.DataSource = queryresult;
                    dgvResult.Columns["iBillNo"].HeaderText      = "帐单号";
                    dgvResult.Columns["vcAssName"].HeaderText    = "会员名称";
                    dgvResult.Columns["vcAssCardID"].HeaderText  = "会员卡号";
                    dgvResult.Columns["dtCreateDate"].HeaderText = "创建日期";
                    dgvResult.Columns["dtPrintDate"].HeaderText  = "上次打印日期";
                    dgvResult.Columns["vcOperName"].HeaderText   = "操作员";
                    dgvResult.Columns["dTotalFee"].HeaderText    = "总金额";
                    dgvResult.Columns["vcPrintFlag"].HeaderText  = "打印次数";
                    dgvResult.Columns["vcCommName"].HeaderText   = "帐单类型";
                }
            }
            catch (Exception ex)
            {
                ErrorLog.Write(this, ex, "查询异常");
            }
        }
Exemplo n.º 35
0
        protected void submit_Click(object sender, EventArgs e)
        {
            string uName = this.uName.Text;
            string uPass = Membership.GeneratePassword(12, 1);
            string uEmail = this.uEmail.Text;
            int companyID = Convert.ToInt32( Request.QueryString["companyID"] );

            AMSEntities ae = new AMSEntities();

            using (TransactionScope t = new TransactionScope())
            {
                /* Add to User .NET Membership */
                //UserProfile + webpages_membership tables
                WebSecurity.CreateUserAndAccount(uName, uPass);

                /* Add User .NET Membership to User Admin Role */
                Roles.AddUserToRole(uName, "User Admin");

                /* Add to Users table */
                User user = new User();
                user.MembershipUserID = WebSecurity.GetUserId(uName);
                user.UserFirstName = this.fName.Text;
                user.UserLastName = this.lName.Text;
                user.UserEmail = uEmail;
                user.UserTitle = this.title.Text;
                user.UserDescription = this.description.Text;
                user.UserPhone = this.phone.Text;
                user.CompanyID = companyID;
                ae.Users.AddObject(user);

                ae.SaveChanges();
                t.Complete();
            }

            string subject = "Your Appointment Management System Account has been created";
            string content = "Dear " + this.title.Text + " " + this.lName.Text + ",";
            content += "\n\n" + "Your username is \"" + uName + "\" and your system generated password is \"" + uPass + "\".";
            content += "\n\n" + "Please change your password after logging in.";
            content += "\n\n" + "Regards,\n" + "The AMS Team";
            Emailer.Send(uEmail, subject, content);

            /* Redirect to new page */
            Server.Transfer("ViewCompanies.aspx", true);
        }
Exemplo n.º 36
0
        public string AddNewUser(FormCollection collection,User user)
        {
            Message = null;
            IsValid=true;
            AMSEntities ae=new AMSEntities();
               // User emailcheck = ae.Users.Where(e => e.UserEmail == user.UserEmail).Single();

             //   if (emailcheck != null)
             //       SetError("Email Id already Exists");

            //User uu=ae.Users.Where(e => e.MembershipUserID == WebSecurity.CurrentUserId).Single();
            User uu = DataStore.Get<User>(e => e.MembershipUserID == WebSecurity.CurrentUserId);
            String uname = collection.Get("UserName");
            String paswd=collection.Get("Password");
            user.CompanyID = uu.CompanyID;
            if (IsValid)
            {
                using (TransactionScope t = new TransactionScope())
                {
                    WebSecurity.CreateUserAndAccount(uname, paswd);
                    Roles.AddUserToRole(uname, "User");
                    user.MembershipUserID = WebSecurity.GetUserId(uname);
                    //ae.Users.AddObject(user);
                    //ae.SaveChanges();
                    DataStore.Create(user);
                    DataStore.SaveChanges();
                    Emailer.Send(user.UserEmail, "Welcome to AMS", "Please reset your password");
                    t.Complete();
                };
                Message="successfully added a new user";
                return Message;
            }
            else
            {
                return Message;
            }
        }
Exemplo n.º 37
0
        public ActionResult ExportUsersList()
        {
            AMSEntities ae = new AMSEntities();
             User uu = ae.Users.Where(e => e.MembershipUserID == WebSecurity.CurrentUserId).Single();
             List<User> users = ae.Users.Where(e => e.CompanyID == uu.CompanyID).ToList();

             var d =(from s in users
                     select new
                     {
                         UserTitle = s.UserTitle ?? null,
                         UserFirstName = s.UserFirstName ?? null,
                         UserLastName = s.UserLastName ?? null,
                         UserEmail = s.UserEmail ?? null,
                         UserPhone = s.UserPhone ?? null,
                                                      }).ToList();

             ReportDocument rd = new ReportDocument();
             rd.Load(Path.Combine(Server.MapPath("~/Reports"), "MyUsers.rpt"));
             rd.SetDataSource(d);

             Response.Buffer = false;
             Response.ClearContent();
             Response.ClearHeaders();

             try
             {
                 Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                 stream.Seek(0, SeekOrigin.Begin);
                 return File(stream, "application/pdf", "MyusersList.pdf");
             }

             catch (Exception e)
             {
                 throw;
             }
        }