Example #1
0
 public static bool UpdateNewDCheckInfo(DCheckInfo CheckInfo, string id, string num, ref string a_strErr)
 {
     if (EquipPro.UpdateDCheckInfo(CheckInfo, id, num, ref a_strErr) >= 1)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #2
0
 public static bool InsertNewDCheckInfo(DCheckInfo CheckInfo, ref string a_strErr)
 {
     if (EquipPro.InsertDCheckInfo(CheckInfo, ref a_strErr) >= 2)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #3
0
        public static DCheckInfo getUpdateDCheckInfo(string id)
        {
            DCheckInfo Check  = new DCheckInfo();
            string     strSql = "select * from tk_DCheckInfo where ID = '" + id + "'";
            DataTable  dt     = SQLBase.FillTable(strSql, "SupplyCnn");

            if (dt.Rows.Count > 0)
            {
                Check.StrECode              = dt.Rows[0]["ECode"].ToString();
                Check.StrCheckDate          = dt.Rows[0]["CheckDate"].ToString();
                Check.StrCheckWay           = dt.Rows[0]["CheckWay"].ToString();
                Check.StrCheckCompany       = dt.Rows[0]["CheckCompany"].ToString();
                Check.StrCharge             = GFun.SafeToFloat(dt.Rows[0]["Charge"].ToString());
                Check.StrPrecision          = dt.Rows[0]["Precision"].ToString();
                Check.StrCensorshipRemark   = dt.Rows[0]["CensorshipRemark"].ToString();
                Check.StrPrincipal          = dt.Rows[0]["Principal"].ToString();
                Check.StrCalibrationResults = dt.Rows[0]["CalibrationResults"].ToString();
            }
            return(Check);
        }
Example #4
0
        public static int UpdateDCheckInfo(DCheckInfo CheckInfo, string id, string num, ref string a_strErr)
        {
            int      intInsert = 0;
            int      intUpdate = 0;
            SQLTrans sqlTrans  = new SQLTrans();

            sqlTrans.Open("SupplyCnn");
            string strInsert = "update tk_DCheckInfo set CheckDate = '" + CheckInfo.StrCheckDate + "',CheckWay = '" + CheckInfo.StrCheckWay + "',CheckCompany = '" + CheckInfo.StrCheckCompany + "',Charge = '" + CheckInfo.StrCharge + "',"
                               + "Precision = '" + CheckInfo.StrPrecision + "',CensorshipRemark = '" + CheckInfo.StrCensorshipRemark + "',Principal = '" + CheckInfo.StrPrincipal + "',CalibrationResults = '" + CheckInfo.StrCalibrationResults + "' where ID = '" + id + "'";
            string strUpdate = "";

            if (num == "1")
            {
                DateTime CheckDate = Convert.ToDateTime(CheckInfo.StrCheckDate); DateTime PlanDate = new DateTime();
                string   strSql = "";
                if (CheckInfo.StrCheckWay == "CK1")
                {
                    strSql = "select CalibrationCycleType,CalibrationCycle from tk_DevicsBas where ECode = '" + CheckInfo.StrECode + "'";
                    DataTable dt        = SQLBase.FillTable(strSql, "SupplyCnn");
                    string    CycelType = dt.Rows[0]["CalibrationCycleType"].ToString();
                    int       Cycel     = Convert.ToInt16(dt.Rows[0]["CalibrationCycle"]);
                    if (CycelType == "Cy1")
                    {
                        PlanDate = CheckDate.AddYears(Cycel);
                    }
                    if (CycelType == "Cy2")
                    {
                        PlanDate = CheckDate.AddMonths(Cycel);
                    }
                    if (CycelType == "Cy3")
                    {
                        PlanDate = CheckDate.AddDays(Cycel);
                    }
                    if (CheckInfo.StrPrecision != null)
                    {
                        strUpdate = "update tk_DevicsBas set LastCalibrationDate = '" + CheckInfo.StrCheckDate + "',PlanCalibrationDate = '" + PlanDate.ToString("yyyy-MM-dd") + "',Precision = '" + CheckInfo.StrPrecision + "' where ECode = '" + CheckInfo.StrECode + "'";
                    }
                    else
                    {
                        strUpdate = "update tk_DevicsBas set LastCalibrationDate = '" + CheckInfo.StrCheckDate + "',PlanCalibrationDate = '" + PlanDate.ToString("yyyy-MM-dd") + "' where ECode = '" + CheckInfo.StrECode + "'";
                    }
                }
                if (CheckInfo.StrCheckWay == "CK2")
                {
                    strSql = "select CheckCycleType,CheckCycle from tk_DevicsBas where ECode = '" + CheckInfo.StrECode + "'";
                    DataTable dt        = SQLBase.FillTable(strSql, "SupplyCnn");
                    string    CycelType = dt.Rows[0]["CheckCycleType"].ToString();
                    int       Cycel     = Convert.ToInt16(dt.Rows[0]["CheckCycle"]);
                    if (CycelType == "Cy1")
                    {
                        PlanDate = CheckDate.AddYears(Cycel);
                    }
                    if (CycelType == "Cy2")
                    {
                        PlanDate = CheckDate.AddMonths(Cycel);
                    }
                    if (CycelType == "Cy3")
                    {
                        PlanDate = CheckDate.AddDays(Cycel);
                    }
                    if (CheckInfo.StrPrecision != null)
                    {
                        strUpdate = "update tk_DevicsBas set LastCheckDate = '" + CheckInfo.StrCheckDate + "',PlanCheckDate = '" + PlanDate.ToString("yyyy-MM-dd") + "',Precision = '" + CheckInfo.StrPrecision + "' where ECode = '" + CheckInfo.StrECode + "'";
                    }
                    else
                    {
                        strUpdate = "update tk_DevicsBas set LastCheckDate = '" + CheckInfo.StrCheckDate + "',PlanCheckDate = '" + PlanDate.ToString("yyyy-MM-dd") + "' where ECode = '" + CheckInfo.StrECode + "'";
                    }
                }
                if (CheckInfo.StrCheckWay == "CK3")
                {
                    strSql = "select TestCycleType,TestCycle from tk_DevicsBas where ECode = '" + CheckInfo.StrECode + "'";
                    DataTable dt        = SQLBase.FillTable(strSql, "SupplyCnn");
                    string    CycelType = dt.Rows[0]["TestCycleType"].ToString();
                    int       Cycel     = Convert.ToInt16(dt.Rows[0]["TestCycle"]);
                    if (CycelType == "Cy1")
                    {
                        PlanDate = CheckDate.AddYears(Cycel);
                    }
                    if (CycelType == "Cy2")
                    {
                        PlanDate = CheckDate.AddMonths(Cycel);
                    }
                    if (CycelType == "Cy3")
                    {
                        PlanDate = CheckDate.AddDays(Cycel);
                    }
                    if (CheckInfo.StrPrecision != null)
                    {
                        strUpdate = "update tk_DevicsBas set LastTestDate = '" + CheckInfo.StrCheckDate + "',PlanTestDate = '" + PlanDate.ToString("yyyy-MM-dd") + "',Precision = '" + CheckInfo.StrPrecision + "' where ECode = '" + CheckInfo.StrECode + "'";
                    }
                    else
                    {
                        strUpdate = "update tk_DevicsBas set LastTestDate = '" + CheckInfo.StrCheckDate + "',PlanTestDate = '" + PlanDate.ToString("yyyy-MM-dd") + "' where ECode = '" + CheckInfo.StrECode + "'";
                    }
                }
            }

            try
            {
                if (strInsert != "")
                {
                    intInsert = sqlTrans.ExecuteNonQuery(strInsert, CommandType.Text, null);
                }
                if (strUpdate != "")
                {
                    intUpdate = sqlTrans.ExecuteNonQuery(strUpdate, CommandType.Text, null);
                }
                sqlTrans.Close(true);
            }
            catch (SqlException e)
            {
                sqlTrans.Close(false);
                a_strErr = e.Message;
                return(-1);
            }

            return(intInsert);
        }
Example #5
0
        public static int InsertDCheckInfo(DCheckInfo CheckInfo, ref string a_strErr)
        {
            int      intInsert = 0;
            int      intUpdate = 0;
            SQLTrans sqlTrans  = new SQLTrans();

            sqlTrans.Open("SupplyCnn");
            string   strInsert = GSqlSentence.GetInsertInfoByD <DCheckInfo>(CheckInfo, "tk_DCheckInfo");
            string   strUpdate = "";
            DateTime CheckDate = Convert.ToDateTime(CheckInfo.StrCheckDate);
            DateTime PlanDate  = new DateTime();
            string   strSql    = "";

            strSql = "select CycleType,Cycle from tk_DevicsBas where ECode = '" + CheckInfo.StrECode + "'";
            DataTable dt        = SQLBase.FillTable(strSql, "SupplyCnn");
            string    CycelType = dt.Rows[0]["CycleType"].ToString();
            int       Cycel     = Convert.ToInt16(dt.Rows[0]["Cycle"]);

            if (CycelType == "Cy1")
            {
                PlanDate = CheckDate.AddYears(Cycel);
            }
            if (CycelType == "Cy2")
            {
                PlanDate = CheckDate.AddMonths(Cycel);
            }
            if (CycelType == "Cy3")
            {
                PlanDate = CheckDate.AddDays(Cycel);
            }
            if (CheckInfo.StrPrecision != null)
            {
                strUpdate = "update tk_DevicsBas set LastDate = '" + CheckInfo.StrCheckDate + "',PlanDate = '" + PlanDate.ToString("yyyy-MM-dd") + "',Precision = '" + CheckInfo.StrPrecision + "' where ECode = '" + CheckInfo.StrECode + "'";
            }
            else
            {
                strUpdate = "update tk_DevicsBas set LastDate = '" + CheckInfo.StrCheckDate + "',PlanDate = '" + PlanDate.ToString("yyyy-MM-dd") + "' where ECode = '" + CheckInfo.StrECode + "'";
            }



            try
            {
                if (strInsert != "")
                {
                    intInsert = sqlTrans.ExecuteNonQuery(strInsert, CommandType.Text, null);
                }
                if (strUpdate != "")
                {
                    intUpdate = sqlTrans.ExecuteNonQuery(strUpdate, CommandType.Text, null);
                }
                sqlTrans.Close(true);
            }
            catch (SqlException e)
            {
                sqlTrans.Close(false);
                a_strErr = e.Message;
                return(-1);
            }

            return(intInsert + intUpdate);
        }