Ejemplo n.º 1
0
 public JObject Add(JObject data)
 {
     try
     {
         DBServer dbserver = new SqlServer();
         dbserver.BeginTranscation();
         PriorityWatch model       = new PriorityWatch(dbserver);
         JArray        data_detail = null;
         JToken        token       = null;
         if (data.TryGetValue("detail", out token) == true)
         {
             data_detail = (JArray)token;
             foreach (JObject items in data_detail)
             {
                 items.Remove("ID");
                 items.Add(new JProperty("ID", GUID.NewGuid()));
             }
         }
         if ((model.Save(data_detail) == 0))
         {
             dbserver.Commit();
             return(ShowSuccess("保存成功."));
         }
         else
         {
             dbserver.Rollback();
             return(ShowExecuteError("保存失败."));
         }
     }
     catch (Exception ex)
     {
         return(ShowExecuteError(ex.Message));
     }
 }
Ejemplo n.º 2
0
        public JObject Add(JObject data)
        {
            DBServer dbserver = new SqlServer();

            try
            {
                String gbl_ID = String.Empty;
                dbserver.BeginTranscation();
                Major   model       = new Major(dbserver);
                Detail  model_D     = new Detail(dbserver);
                JToken  token       = null;
                JArray  data_detail = null;
                JObject data_mian   = null;
                if (data.TryGetValue("main", out token) == true)
                {
                    data_mian = (JObject)token;
                    data_mian.Add(new JProperty("ID", GUID.NewGuid()));
                    gbl_ID = data_mian["ID"].ToString().Replace("\"", "").Trim();
                }
                if (data.TryGetValue("detail", out token) == true)
                {
                    data_detail = (JArray)token;
                    foreach (JObject items in data_detail)
                    {
                        items.Remove("ID");
                        items.Add(new JProperty("ID", GUID.NewGuid()));
                        items.Add(new JProperty("nvcAttendanceID", gbl_ID));
                    }
                }
                if (model.Create(data_mian) && (model_D.Save(data_detail) == 0))
                {
                    dbserver.Commit();
                    return(ShowSuccess("保存成功."));
                }
                else
                {
                    dbserver.Rollback();
                    return(ShowExecuteError("保存失败."));
                }
            }
            catch (Exception ex)
            {
                dbserver.Rollback();
                return(ShowExecuteError(ex.Message));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 执行考勤结果提交 2015-08-18 15:06:07
        /// </summary>
        /// <param name="context"></param>
        public void AttendanceAtt(HttpContext context)
        {
            string json = "{\"success\":false}";

            string nvcElectiveNum = context.Request.Form["nvcElectiveNum"];
            string nvcLoginCode   = context.Request.Form["nvcLoginCode"];
            string absentNo       = context.Request.Form["absentNo"];
            string nvcIP          = context.Request.Form["nvcIP"];
            string nvcTerminal    = context.Request.Form["nvcTerminal"];

            string[] students = absentNo.Split(';');

            DBServer dbserver = new SqlServer();

            try
            {
                dbserver.BeginTranscation();
                string  cmd          = string.Format("insert into {0} (nvcElectiveNum,nvcLoginCode,nvcRollWay,intRollCount,nvcIP,nvcTerminal) output inserted.ID Values('{1}','{2}','全点',(select MAX(intRollCount) from {0} where nvcElectiveNum='{1}')+1,'{3}','{4}');", AMTable, nvcElectiveNum, nvcLoginCode, nvcIP, nvcTerminal);
                DataRow row          = dbserver.ExecuteRow(cmd);
                string  attendanceID = row["ID"].ToString();
                int     n            = 0;
                if (students[0] != "")
                {
                    for (int i = 0; i < students.Length; i++)
                    {
                        string[] temp    = students[i].Split(',');
                        string   cmdText = string.Format("insert into {0} (nvcAttendanceID,nvcStuNo,nvcReason)Values('{1}','{2}','{3}');", ADTable, attendanceID, temp[0], temp[1]);
                        n += dbserver.ExecuteNonQuery(cmdText);
                    }
                }
                dbserver.Commit();
                json = "{\"success\":true,\"index\":\"" + n + "\"}";
            }
            catch
            {
                dbserver.Rollback();
            }
            context.Response.Write(json);
        }