Esempio n. 1
0
 public string[] setAidsManageData(createAidsManage StructData)
 {
     string[] returnValue = new string[2];
     returnValue[0] = "0";
     returnValue[1] = "";
     DataBase Base = new DataBase();
     using (SqlConnection Sqlconn = new SqlConnection(Base.GetConnString()))
     {
         try
         {
             StaffDataBase sDB = new StaffDataBase();
             List<string> CreateFileName = sDB.getStaffDataName(HttpContext.Current.User.Identity.Name);
             Sqlconn.Open();
             string sql = "UPDATE HearingAidsManage SET AidsStatu =@AidsStatu, HearingAidsID =@HearingAidsID, AidsType =@AidsType, "+
                 "AidsBrand =@AidsBrand, AidsModel =@AidsModel, HearingAidsNo =@HearingAidsNo, AidsSource =@AidsSource, "+
                 "WriteDate =@WriteDate, Remark =@Remark, UpFileBy=@UpFileBy, UpFileDate=getDate()  " +
                 "WHERE ID=@ID";
             SqlCommand cmd = new SqlCommand(sql, Sqlconn);
             cmd.Parameters.Add("@ID", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(StructData.ID);
             cmd.Parameters.Add("@AidsStatu", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StructData.aStatu);
             cmd.Parameters.Add("@HearingAidsID", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StructData.aID);
             cmd.Parameters.Add("@AidsType", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StructData.assistmanage);
             cmd.Parameters.Add("@AidsBrand", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StructData.brand);
             cmd.Parameters.Add("@AidsModel", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StructData.model);
             cmd.Parameters.Add("@HearingAidsNo", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StructData.aNo);
             cmd.Parameters.Add("@AidsSource", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StructData.aSource);
             cmd.Parameters.Add("@WriteDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(StructData.fillInDate);
             cmd.Parameters.Add("@Remark", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StructData.remark);
             cmd.Parameters.Add("@UpFileBy", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(CreateFileName[0]);
             returnValue[0] = cmd.ExecuteNonQuery().ToString();
             Sqlconn.Close();
         }
         catch (Exception e)
         {
             returnValue[0] = "-1";
             returnValue[1] = e.Message.ToString();
         }
     }
     return returnValue;
 }
Esempio n. 2
0
    public string[] createAidsManageData(createAidsManage StructData)
    {
        string[] returnValue = new string[2];
        returnValue[0] = "0";
        returnValue[1] = "";
        DataBase Base = new DataBase();
        using (SqlConnection Sqlconn = new SqlConnection(Base.GetConnString()))
        {
            try
            {
                StaffDataBase sDB = new StaffDataBase();
                List<string> CreateFileName = sDB.getStaffDataName(HttpContext.Current.User.Identity.Name);
                Sqlconn.Open();
                string sql = "INSERT INTO HearingAidsManage (Unit, AidsStatu, HearingAidsID, AidsType, AidsBrand, AidsModel, HearingAidsNo, " +
                    "AidsSource, WriteDate, Remark, CreateFileBy, UpFileBy, UpFileDate) " +
                    "VALUES(@Unit, @AidsStatu, @HearingAidsID, @AidsType, @AidsBrand, @AidsModel, @HearingAidsNo, @AidsSource, @WriteDate, "+
                    "@Remark, @CreateFileBy, @UpFileBy, (getDate()))";
                SqlCommand cmd = new SqlCommand(sql, Sqlconn);
                cmd.Parameters.Add("@Unit", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(CreateFileName[2].ToString());
                cmd.Parameters.Add("@AidsStatu", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StructData.aStatu);
                cmd.Parameters.Add("@HearingAidsID", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StructData.aID);
                cmd.Parameters.Add("@AidsType", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StructData.assistmanage);
                cmd.Parameters.Add("@AidsBrand", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(StructData.brand);
                cmd.Parameters.Add("@AidsModel", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StructData.model);
                cmd.Parameters.Add("@HearingAidsNo", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StructData.aNo);
                cmd.Parameters.Add("@AidsSource", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StructData.aSource);
                cmd.Parameters.Add("@WriteDate",SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(StructData.fillInDate);
                cmd.Parameters.Add("@Remark", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(StructData.remark);
                cmd.Parameters.Add("@CreateFileBy", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(CreateFileName[0]);
                cmd.Parameters.Add("@UpFileBy", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(CreateFileName[0]);
                returnValue[0] = cmd.ExecuteNonQuery().ToString();

                if (returnValue[0] != "0")
                {
                    sql = "select IDENT_CURRENT('HearingAidsManage') AS cID";
                    cmd = new SqlCommand(sql, Sqlconn);
                    SqlDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        returnValue[1] = dr["cID"].ToString();
                    }
                    dr.Close();
                }
                Sqlconn.Close();
            }
            catch (Exception e)
            {
                returnValue[0] = "-1";
                returnValue[1] = e.Message.ToString();
            }
        }
        return returnValue;
    }
Esempio n. 3
0
 public string[] setAidsManageDataBase(createAidsManage StructData)
 {
     Audiometry aDB = new Audiometry();
     return aDB.setAidsManageData(StructData);
 }
Esempio n. 4
0
    public createAidsManage getAidsManageData(string sID)
    {
        createAidsManage returnValue = new createAidsManage();
        returnValue.LoanList = new List<createAidsManageLoan>();
        returnValue.ServiceList = new List<createAidsManageService>();
        DataBase Base = new DataBase();
        using (SqlConnection Sqlconn = new SqlConnection(Base.GetConnString()))
        {
            try
            {
                StaffDataBase sDB = new StaffDataBase();
                Sqlconn.Open();
                string sql = "SELECT * FROM HearingAidsManage WHERE ID=@ID AND isDeleted=0";
                SqlCommand cmd = new SqlCommand(sql, Sqlconn);
                cmd.Parameters.Add("@ID", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(sID);
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    returnValue.ID = dr["ID"].ToString();
                    returnValue.Unit = dr["Unit"].ToString();
                    returnValue.aStatu = dr["AidsStatu"].ToString();
                    returnValue.aID = dr["HearingAidsID"].ToString();
                    returnValue.assistmanage = dr["AidsType"].ToString();
                    returnValue.brand = dr["AidsBrand"].ToString();
                    returnValue.model = dr["AidsModel"].ToString();
                    returnValue.aNo = dr["HearingAidsNo"].ToString();
                    returnValue.aSource = dr["AidsSource"].ToString();
                    returnValue.fillInDate = DateTime.Parse(dr["WriteDate"].ToString()).ToString("yyyy-MM-dd");
                    returnValue.remark = dr["Remark"].ToString();
                }
                dr.Close();

                sql = "SELECT HearingAidsManageLoanRecord.*,StudentDatabase.StudentName FROM HearingAidsManageLoanRecord " +
                      "LEFT JOIN StudentDatabase ON HearingAidsManageLoanRecord.OutPeople=StudentDatabase.StudentID "+
                      "WHERE ManageID=@mID AND HearingAidsManageLoanRecord.isDeleted=0 ORDER BY OutDate DESC";
                cmd = new SqlCommand(sql, Sqlconn);
                cmd.Parameters.Add("@mID", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(returnValue.ID);
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    createAidsManageLoan addValue = new createAidsManageLoan();
                    addValue.ID= dr["ID"].ToString();
                    addValue.mID = dr["ManageID"].ToString();
                    addValue.lendDate = DateTime.Parse(dr["OutDate"].ToString()).ToString("yyyy-MM-dd");
                    addValue.lendPeople = dr["StudentName"].ToString();
                    addValue.lendPeopleID = dr["OutPeople"].ToString();
                    addValue.returnDate = DateTime.Parse(dr["ScheduledReturnDate"].ToString()).ToString("yyyy-MM-dd");
                    addValue.returnDate2 = DateTime.Parse(dr["ReturnDate"].ToString()).ToString("yyyy-MM-dd");
                    addValue.remark = dr["Remark"].ToString();
                    returnValue.LoanList.Add(addValue);
                }
                dr.Close();
                sql = "SELECT * FROM HearingAidsManageMaintenanceRecord WHERE ManageID=@mID AND isDeleted=0 ORDER BY MaintenanceDate DESC";
                cmd = new SqlCommand(sql, Sqlconn);
                cmd.Parameters.Add("@mID", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(returnValue.ID);
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    createAidsManageService addValue2 = new createAidsManageService();
                    addValue2.ID = dr["ID"].ToString();
                    addValue2.mID = dr["ManageID"].ToString();
                    addValue2.serviceDate = DateTime.Parse(dr["MaintenanceDate"].ToString()).ToString("yyyy-MM-dd");
                    addValue2.serviceItem = dr["Reason"].ToString();
                    addValue2.serviceFirm = dr["MaintenanceVendor"].ToString();
                    addValue2.serviceFirmDate = DateTime.Parse(dr["ReturnDate"].ToString()).ToString("yyyy-MM-dd");
                    addValue2.sRemark = dr["Remark"].ToString();
                    returnValue.ServiceList.Add(addValue2);
                }
                dr.Close();
                Sqlconn.Close();
            }
            catch (Exception e)
            {
                returnValue.checkNo = "-1";
                returnValue.errorMsg = e.Message.ToString();
            }
        }
        return returnValue;
    }
Esempio n. 5
0
 public string[] createAidsManageDataBase(createAidsManage StructData)
 {
     Audiometry aDB = new Audiometry();
     if (int.Parse(aDB._StaffhaveRoles[2]) == 1)
     {
         return aDB.createAidsManageData(StructData);
     }
     else
     {
         return new string[2] { _noRole, _errorMsg };
     }
 }