Exemplo n.º 1
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name="student"></param>
        /// <returns></returns>
        public bool insert(Student student)
        {
            string sql = "insert into student (classId, birthday, img, studentName, sex) values ('{0}', '{1}', '{2}', '{3}', '{4}')";

            sql = string.Format(sql, student.classId, student.birthday, student.img, student.studentName, student.sex);
            List <string> sqlList = new List <string>();

            sqlList.Add(sql);
            bool isSuccess = SQLHelper.ExecuteTransaction(sqlList);

            return(isSuccess);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 结账
        /// </summary>
        /// <param name="objSaleList"></param>
        /// <param name="member"></param>
        /// <returns></returns>
        public bool SaveSaleInfo(SalesListMain objSaleList, SMMembers member)
        {
            List <string> sqlList = new List <string>();
            //【1】组合sql语句(插入主表)
            string mainSql = "insert into SalesList(SerialNum, TotalMoney, RealReceive, ReturnMoney, SalesPersonId) values('{0}',{1},{2},{3},{4})";

            mainSql = string.Format(mainSql, objSaleList.SeriaINum, objSaleList.TotalMoney, objSaleList.RealRecieve, objSaleList.ReturnMoney, objSaleList.SalesPersonId);
            sqlList.Add(mainSql);
            //【2】组合sql语句(插入明细表以及更新库存)
            foreach (SalesListDetail detail in objSaleList.ListDetail)
            {
                //插入明细表
                string detailSql = "insert into SalesListDetail(SerialNum, ProductId, ProductName, UnitPrice, Discount, Quantity, SubTotalMoney)";
                detailSql += " values('{0}','{1}','{2}',{3},{4},{5},{6})";
                detailSql  = string.Format(detailSql, detail.SeriaINum, detail.ProductId, detail.ProductName, detail.UnitPrice, detail.Discount, detail.Quantity, detail.SubTotalMoney);
                sqlList.Add(detailSql);
                //跟新库存
                string updateSql = $"update ProductInventory set TotalCount=TotalCount-{detail.Quantity} where ProductId='{detail.ProductId}'";
                sqlList.Add(updateSql);
            }
            //【3】更新客户积分
            if (member != null)
            {
                string pointSql = "update SMMembers set Points=Points+{0} where MemberId={1}";
                pointSql = string.Format(pointSql, member.Points, member.MemeberId);
                sqlList.Add(pointSql);
            }
            try
            {
                //【4】启用事务,返回结果
                return(SQLHelper.ExecuteTransaction(sqlList));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        public bool Import(List <StudentExt> studentList)
        {
            string sql = "insert into Students(StudentName, Gender, Birthday, StudentIdNo, CardNo, Age, PhoneNumber, StudentAddress, ClassId)";

            sql += " values('{0}','{1}','{2}',{3},'{4}',{5},'{6}','{7}',{8});";
            List <string> sqlList = new List <string>();

            foreach (var student in studentList)
            {
                string sql1 = string.Format(sql, student.StudentName, student.Gender, student.Birthday, student.StudentIdNo, student.CardNo,
                                            student.Age, student.PhoneNumber, student.StudentAddress, student.ClassId);
                sqlList.Add(sql1);
            }
            //将Slq语句提交到数据库
            try
            {
                //返回学号
                return(SQLHelper.ExecuteTransaction(sqlList));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }