예제 #1
0
        public static bool PeriodBakingZeroTimer(int devicenumber)
        {
            try
            {
                SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Update_Zero_Autoclav", cn);

                cmd.Parameters.AddWithValue("intTimeStart", Convert.ToInt32(Varibale.Status_Baking[devicenumber]));

                cmd.Parameters.AddWithValue("intTimezero", PublicMehotd.time_php());

                cmd.Parameters.AddWithValue("timezero", PublicMehotd.RetStringLocalTime());

                cmd.Parameters.AddWithValue("kind", Enum.EnumKindDevice.baking.ToString());

                cmd.Parameters.AddWithValue("dev_no", devicenumber);

                cn.Open();
                object obj = cmd.ExecuteScalar();
                cn.Close();



                return(true);
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "period-baking-zero timer");
                Enum.ClassEnumError.ShowErrorInMessageBox(Enum.EnumError.updatePeriodAutoclavZeroError);
                return(false);
            }
        }
예제 #2
0
        private static void updateFirstData(int id, string[] RecordData)
        {
            string sql = "";

            try {
                string[] FirstData    = calculatefirstData(id, RecordData);
                string   timeStart    = FirstData[1];
                string   intTimeStart = FirstData[0];
                string   datep        = FirstData[2];
                string   yearp        = FirstData[3];
                string   monthp       = FirstData[4];
                string   dayp         = FirstData[5];

                sql = "update zarin_report_counter set  intTimeStart = '" + intTimeStart
                      + "' , timeStart = '" + timeStart
                      + "' , datep = '" + datep
                      + "' , yearp = '" + yearp
                      + "' , monthp = '" + monthp
                      + "' , dayp = '" + dayp
                      + "' , updateStartSuccess = '1' where id = " + id + " ";

                SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(CommandType.Text, sql, cn);
                cn.Open();
                cmd.ExecuteNonQuery();
                cn.Close();
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "zarin report update   record first data =" + sql);
            }
        }
예제 #3
0
        public bool PeriodAutoclavStart()
        {
            try
            {
                string timeStartAutoclav = PublicMehotd.time_php();

                //MessageBox.Show((Convert.ToInt32(timeStartAutoclav) - Varibale.Timer_Autoclav[Dev_no]).ToString() + " X " + timeStartAutoclav);

                Varibale.Status_Autoclav[Dev_no] = (Convert.ToInt32(timeStartAutoclav) - Varibale.Timer_Autoclav[Dev_no]).ToString();

                SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Insert_start_New_Period", cn);

                cmd.Parameters.AddWithValue("dev_no", Dev_no);

                cmd.Parameters.AddWithValue("status", Enum.EnumStatusPeriod.start.ToString());

                cmd.Parameters.AddWithValue("kind", Enum.EnumKindDevice.autoclav.ToString());

                cmd.Parameters.AddWithValue("intTimestart", (Convert.ToInt32(timeStartAutoclav) - Varibale.Timer_Autoclav[Dev_no]).ToString());

                cmd.Parameters.AddWithValue("intTimeend", 0);

                cmd.Parameters.AddWithValue("timestart", PublicMehotd.RetStringLocalTime(-1 * Varibale.Timer_Autoclav[Dev_no]));

                cmd.Parameters.AddWithValue("timeend", "00:00:00");

                cmd.Parameters.AddWithValue("date", PublicMehotd.RetStringPersianCalender());

                cmd.Parameters.AddWithValue("year", PublicMehotd.retStringYearPersian());

                cmd.Parameters.AddWithValue("month", PublicMehotd.retStringMonthPersian());

                cmd.Parameters.AddWithValue("day", PublicMehotd.retStringDayPersian());

                cmd.Parameters.AddWithValue("intTimezero", "0");

                cmd.Parameters.AddWithValue("timezero", "00:00:00");

                cmd.Parameters.AddWithValue("time_st", Varibale.Data_Timer_Max[Dev_no].ToString());

                cmd.Parameters.AddWithValue("temp_low_st", Varibale.Data_Temp_Min[Dev_no]);

                cmd.Parameters.AddWithValue("temp_high_st", Varibale.Data_Temp_Max[Dev_no]);

                cmd.Parameters.AddWithValue("pres_st", Varibale.Data_Pres_Min[Dev_no]);

                cn.Open();
                object obj = cmd.ExecuteScalar();
                cn.Close();

                return(true);
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "period-start-autoclav");
                Enum.ClassEnumError.ShowErrorInMessageBox(Enum.EnumError.insertnewstartautoclavinsertdatabaseerror);
                return(false);
            }
        }
예제 #4
0
        private static void endRecord(int id, Int64 number, string[] RecordData)
        {
            string sql = "";

            try {
                string[] endRecord  = calculateLastData(id, number, RecordData);
                string   intTimeEnd = endRecord[0];
                string   timeEnd    = endRecord[1];
                string   timeUpdate = timeEnd;

                sql = "update zarin_report_counter set status = 'end' , number = '" + number
                      + "' , intTimeEnd = '" + intTimeEnd
                      + "' , timeEnd = '" + timeEnd
                      + "' , timeUpdate = '" + timeUpdate
                      + "' where id = " + id + " ";

                SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(CommandType.Text, sql, cn);
                cn.Open();
                cmd.ExecuteNonQuery();
                cn.Close();
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "zarin report end  record =" + sql);
            }
        }
예제 #5
0
        private void NewLogInsertToDatabase()
        {
            try
            {
                SqlConnection cn = ConnectToDatabase.NewConnectToDatabase();

                SqlCommand cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Insert_Log_New", cn);

                cmd.Parameters.AddWithValue("dev_no", DeviceNumber);
                cmd.Parameters.AddWithValue("kind", Kind.ToString());
                cmd.Parameters.AddWithValue("comment", classEnumLog.ShowError(Type));
                cmd.Parameters.AddWithValue("level", Level.ToString());
                cmd.Parameters.AddWithValue("intTime", (Convert.ToInt32(PublicMehotd.time_php()) + Sec));
                cmd.Parameters.AddWithValue("datep", PublicMehotd.RetStringPersianCalender());
                cmd.Parameters.AddWithValue("timep", PublicMehotd.RetStringLocalTime(Sec));
                cmd.Parameters.AddWithValue("datetimep", PublicMehotd.retStringShowDatetime());
                cmd.Parameters.AddWithValue("value", Val);
                cmd.Parameters.AddWithValue("yearp", PublicMehotd.retStringYearPersian());
                cmd.Parameters.AddWithValue("monthp", PublicMehotd.retStringMonthPersian());
                cmd.Parameters.AddWithValue("dayp", PublicMehotd.retStringDayPersian());

                cn.Open();
                object obj = cmd.ExecuteScalar();
                cn.Close();
            }
            catch (Exception ex)
            {
                //Enum.ClassEnumError.ShowErrorInMessageBox(EnumError.insertNewLogProbel);
                log_system.saveLogSystem(ex, "log_manager insert");
            }
        }
예제 #6
0
        private static string[] calculatefirstData(int id, string[] RecordData)
        {
            //string[] RecordData = getRecordReportProduct(id);
            string intTimeStart = RecordData[8];
            string Counter_num  = RecordData[10];
            string timeStart    = RecordData[11];
            string dayp         = RecordData[13];
            string monthp       = RecordData[14];
            string yearp        = RecordData[15];
            string datep        = RecordData[16];

            string sql = "";

            string[] x = new string[10];
            try
            {
                sql = "select top 1 * from Data  where type = 'count' and device_no = '" + Counter_num
                      + "' and intTime > '" + intTimeStart
                      + "' and id < (select top 1 id from Data where type = 'count' and device_no = '" + Counter_num
                      + "' and intTime > '" + intTimeStart
                      + "' and value != '0' order by id ) order by id desc";

                SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(CommandType.Text, sql, cn);
                cn.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    x[0] = dr["intTime"].ToString();
                    x[1] = dr["timep"].ToString();
                    x[2] = dr["datep"].ToString();
                    x[3] = dr["yearp"].ToString();
                    x[4] = dr["monthp"].ToString();
                    x[5] = dr["dayp"].ToString();


                    cn.Close();
                    return(x);
                }
                else
                {
                    x[0] = intTimeStart;
                    x[1] = timeStart;
                    x[2] = datep;
                    x[3] = yearp;
                    x[4] = monthp;
                    x[5] = dayp;
                    cn.Close();
                    return(x);
                }
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "zarin report end  record first data =" + sql);
                return(null);
            }
        }
        public static void FreeSpace()
        {
            SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
            SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(CommandType.Text, "DBCC ShrinkDataBase (DB_Monitoring, 0)", cn);

            cn.Open();

            cmd.ExecuteNonQuery();

            cn.Close();
        }
예제 #8
0
        private static void removeNumberZero(int num)
        {
            string sql = "delete from zarin_report_counter " +
                         "where counter_num = " + num + " and status = 'end' and number = 0 ";

            SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
            SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(CommandType.Text, sql, cn);

            cn.Open();
            cmd.ExecuteNonQuery();
            cn.Close();
        }
예제 #9
0
        public bool PeriodBakingStart()
        {
            try
            {
                string timeStartBaking = PublicMehotd.time_php();

                Varibale.Status_Baking[Dev_no] = timeStartBaking.ToString();

                SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Insert_start_New_Period", cn);

                cmd.Parameters.AddWithValue("dev_no", Dev_no);

                cmd.Parameters.AddWithValue("status", Enum.EnumStatusPeriod.start.ToString());

                cmd.Parameters.AddWithValue("kind", Enum.EnumKindDevice.baking.ToString());

                cmd.Parameters.AddWithValue("intTimestart", timeStartBaking);

                cmd.Parameters.AddWithValue("intTimeend", 0);

                cmd.Parameters.AddWithValue("timestart", PublicMehotd.RetStringLocalTime());

                cmd.Parameters.AddWithValue("timeend", "00:00:00");

                cmd.Parameters.AddWithValue("date", PublicMehotd.RetStringPersianCalender());

                cmd.Parameters.AddWithValue("year", PublicMehotd.retStringYearPersian());

                cmd.Parameters.AddWithValue("month", PublicMehotd.retStringMonthPersian());

                cmd.Parameters.AddWithValue("day", PublicMehotd.retStringDayPersian());

                cmd.Parameters.AddWithValue("intTimezero", "0");

                cmd.Parameters.AddWithValue("timezero", "00:00:00");

                cn.Open();
                object obj = cmd.ExecuteScalar();
                cn.Close();



                return(true);
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "period-baking-start");
                Enum.ClassEnumError.ShowErrorInMessageBox(Enum.EnumError.insertnewstartautoclavinsertdatabaseerror);
                return(false);
            }
        }
예제 #10
0
        public static bool InsertToDatabase(int devicenumber, Enum.EnumTypeData type, Enum.EnumKindDevice kind, double value)
        {
            try
            {
                Boolean check = true;

                if (check)
                {
                    SqlConnection cn = ConnectToDatabase.NewConnectToDatabase();

                    SqlCommand cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Insert_Data_new", cn);

                    cmd.Parameters.AddWithValue("dev_no", devicenumber);
                    cmd.Parameters.AddWithValue("type", type.ToString());
                    cmd.Parameters.AddWithValue("kind", kind.ToString());
                    cmd.Parameters.AddWithValue("value", value);
                    cmd.Parameters.AddWithValue("intTime", PublicMehotd.time_php());
                    cmd.Parameters.AddWithValue("datep", PublicMehotd.RetStringPersianCalender());
                    cmd.Parameters.AddWithValue("timep", PublicMehotd.RetStringLocalTime());
                    cmd.Parameters.AddWithValue("yearp", PublicMehotd.retStringYearPersian());
                    cmd.Parameters.AddWithValue("monthp", PublicMehotd.retStringMonthPersian());
                    cmd.Parameters.AddWithValue("dayp", PublicMehotd.retStringDayPersian());
                    cmd.Parameters.AddWithValue("datetimep", Convert.ToDouble(PublicMehotd.retStringShowDatetime()));

                    cn.Open();
                    object obj = cmd.ExecuteScalar();
                    cn.Close();

                    if (Autoclav.sendServer_count == Varibale.save_count_autoclav_server)
                    {
                        Autoclav.sendServer_count = 0;
                    }
                    else
                    {
                        Autoclav.sendServer_count++;
                    }


                    return(true);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "autoclav-insert database");
                //Enum.ClassEnumError.ShowErrorInMessageBox(Enum.EnumError.insertnewDatalogforautoclav);
                return(false);
            }
        }
예제 #11
0
        private static void closeAllRcord(int num)
        {
            string sql = "update zarin_report_counter set status = 'end' ,timeEnd='" + PublicMehotd.RetStringLocalTime()
                         + "' , intTimeEnd = '" + PublicMehotd.time_php() + "'  where counter_num = " + num + " and  status = 'counts' ";

            SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
            SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(CommandType.Text, sql, cn);

            cn.Open();
            cmd.ExecuteNonQuery();
            cn.Close();

            removeNumberZero(num);
        }
예제 #12
0
        private static string[] getRecordReportProduct(int id)
        {
            string sql = "select * from zarin_report_counter where id ='" + id
                         + "'  ";

            try
            {
                string[]      x   = new string[25];
                SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(CommandType.Text, sql, cn);


                cn.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    x[0]  = dr["id"].ToString();
                    x[1]  = dr["counter_num"].ToString();
                    x[2]  = dr["number"].ToString();
                    x[3]  = dr["zarin_product"].ToString();
                    x[4]  = dr["brand"].ToString();
                    x[5]  = dr["darb"].ToString();
                    x[6]  = dr["vazn"].ToString();
                    x[7]  = dr["baste_bandi"].ToString();
                    x[8]  = dr["intTimeStart"].ToString();
                    x[9]  = dr["intTimeEnd"].ToString();
                    x[10] = dr["counter_num"].ToString();
                    x[11] = dr["timeStart"].ToString();
                    x[12] = dr["timeEnd"].ToString();
                    x[13] = dr["dayp"].ToString();
                    x[14] = dr["monthp"].ToString();
                    x[15] = dr["yearp"].ToString();
                    x[16] = dr["datep"].ToString();
                    x[17] = dr["updateStartSuccess"].ToString();

                    cn.Close();
                    return(x);
                }
                else
                {
                    cn.Close();
                    return(null);
                }
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "error get last data counter " + sql + " XX " + id);
                return(null);
            }
        }
예제 #13
0
        private static void newRecord(int num, Int64 number)
        {
            zarinReport.closeAllRcord(num);

            string type = "";

            if (num == 1 || num == 2)
            {
                type = "ghabl";
            }
            else
            {
                type = "bad";
            }

            string sql = "insert into zarin_report_counter" +
                         " (status , intTimeStart , intTimeEnd, timeStart, timeEnd , datep  , yearp , monthp , dayp , number , zarin_product , brand , vazn , baste_bandi , darb , counter_num )" +
                         " values " +
                         " ('counts' , '" +
                         PublicMehotd.time_php() + "' , '0' , '" +
                         PublicMehotd.RetStringLocalTime() + "' , '00:00:00' , '" +
                         PublicMehotd.RetStringPersianCalender() + "' , '" +
                         PublicMehotd.retStringYearPersian() + "' , '" +
                         PublicMehotd.retStringMonthPersian() + "' , '" +
                         PublicMehotd.retStringDayPersian() + "' , '" +
                         number.ToString() + "' , '" +
                         ClassEnumProduct.getProductZarinNumber(Convert.ToInt64(Varibale.zarin["zarin_product_" + type]))
                         + "' , '" +
                         Varibale.zarin["brand_" + type]
                         + "' , '" +
                         Varibale.zarin["vazn_" + type]
                         + "' ,  '" +
                         Varibale.zarin["baste_bandi_" + type]
                         + "' , '" +
                         Varibale.zarin["darb_" + type]
                         + "' , '" +
                         num.ToString()
                         + "')";

            SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
            SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(CommandType.Text, sql, cn);

            cn.Open();
            cmd.ExecuteNonQuery();
            cn.Close();
        }
예제 #14
0
        private static string[] calculateLastData(int id, Int64 number, string[] RecordData)
        {
            string NOWEND = PublicMehotd.time_php();

            //string[] RecordData = getRecordReportProduct(id);
            string intTimeEnd  = RecordData[9];
            string Counter_num = RecordData[10];
            string timeEnd     = RecordData[12];

            string[] x   = new string[10];
            string   sql = "";

            try
            {
                sql = "select top 1  * from Data where type = 'count' and device_no = '" + Counter_num
                      + "' and intTime < '" + NOWEND + "' and value in ( select  top 1 value from Data where type = 'count' and device_no = '" + Counter_num
                      + "'and intTime < '" + NOWEND + "'  order by id desc ) order by id asc";

                SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(CommandType.Text, sql, cn);
                cn.Open();
                SqlDataReader dr = cmd.ExecuteReader();

                if (dr.Read())
                {
                    x[0] = dr["intTime"].ToString();
                    x[1] = dr["timep"].ToString();


                    cn.Close();
                    return(x);
                }
                else
                {
                    x[0] = PublicMehotd.time_php();
                    x[1] = PublicMehotd.RetStringLocalTime();
                    cn.Close();
                    return(x);
                }
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "zarin report end  record last data=" + sql);
                return(null);
            }
        }
예제 #15
0
        public static bool PeriodAutoclavNaghes(int deviceNumber)
        {
            try
            {
                if (Varibale.Status_Autoclav[deviceNumber] != "")
                {
                    SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                    SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Update_End_autoclav", cn);

                    cmd.Parameters.AddWithValue("intTimeStart", Varibale.Status_Autoclav[deviceNumber]);

                    cmd.Parameters.AddWithValue("kind", Enum.EnumKindDevice.autoclav.ToString());

                    cmd.Parameters.AddWithValue("dev_no", deviceNumber);

                    cmd.Parameters.AddWithValue("intTimeend", PublicMehotd.time_php());

                    cmd.Parameters.AddWithValue("timeend", PublicMehotd.RetStringLocalTime());

                    cmd.Parameters.AddWithValue("status", Enum.EnumStatusPeriod.naghes.ToString());

                    cn.Open();
                    cmd.ExecuteNonQuery();
                    cn.Close();



                    Varibale.Status_Autoclav[deviceNumber] = "";

                    return(true);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "period-autoclav naghes");
                Enum.ClassEnumError.ShowErrorInMessageBox(Enum.EnumError.updatePeriodAutoclavEndNaghes);
                return(false);
            }
        }
예제 #16
0
        private static void updateRecord(int id, Int64 number, string status)
        {
            string[] RecordData   = getRecordReportProduct(id);
            string   statusUpdate = RecordData[17];

            try {
                if (status == "end")
                {
                    endRecord(id, number, RecordData);
                }
                else
                {
                    string intTimeEnd      = "0";
                    string timeEnd         = "00:00:00";
                    string timeUpdateQuery = ", timeUpdate = '" + PublicMehotd.RetStringLocalTime() + "' ";
                    string sql             = "update zarin_report_counter set status = '" + status
                                             + "' , number = '" + number
                                             + "' , intTimeEnd = '" + intTimeEnd
                                             + "' , timeEnd = '" + timeEnd
                                             + "' " + timeUpdateQuery
                                             + " where id = " + id + " ";

                    SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                    SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(CommandType.Text, sql, cn);
                    cn.Open();
                    cmd.ExecuteNonQuery();
                    cn.Close();

                    if (number > 1000 && statusUpdate == "0")
                    {
                        updateFirstData(id, RecordData);
                    }
                }
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "zarin report update record ");
            }
        }
예제 #17
0
        public static bool SetDataToDatabase(string name, string value)
        {
            try
            {
                SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(CommandType.Text, "update Master_variable set value='" + value + "' where name='" + name + "' ", cn);

                cn.Open();


                cmd.ExecuteNonQuery();

                cn.Close();

                return(true);
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "");
                return(false);
            }
        }
예제 #18
0
        public static long fetchData(int devicenumber, string type, string datep)
        {
            string        sql = "select top 1* from Data where device_no = '" + devicenumber + "' and kind='" + Enum.EnumKindDevice.counter.ToString() + "' and datep='" + datep + "' ORDER BY intTime " + type + " ";
            SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
            SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.Text,
                                                                sql, cn);

            //MessageBox.Show(sql);
            cn.Open();
            SqlDataReader dr = cmd.ExecuteReader();

            if (dr.Read())
            {
                return(Int64.Parse(dr["value"].ToString()));
            }
            else
            {
                return(0);
            }



            cn.Close();
        }
예제 #19
0
        public static void SetFromDatabaseToVarible()
        {
            try
            {
                SqlConnection cn = ConnectToDatabase.NewConnectToDatabase();

                SqlCommand cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Select_All_Varible", cn);

                cn.Open();

                SqlDataReader dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    try
                    {
                        switch (dr["name"].ToString())
                        {
                        case "Autoclav_temp_max":
                            Varibale.Autoclav_Temp_High = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Autoclav_temp_min":
                            Varibale.Autoclav_Temp_Low = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Autoclav_pres_max":
                            Varibale.Autoclav_Pres_high = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Autoclav_pres_min":
                            Varibale.Autoclav_Pres_Low = Convert.ToDouble(dr["value"].ToString());// 0.2 => error
                            break;

                        case "Autoclav_timer_max":
                            Varibale.Autoclav_Timer_max = Convert.ToInt32(dr["value"].ToString());
                            break;


                        case "Baking_temp_max":
                            Varibale.Baking_Temp_High = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Baking_temp_min":
                            Varibale.Baking_Temp_Low = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Baking_pres_max":
                            Varibale.Baking_Pres_high = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Baking_pres_min":
                            Varibale.Baking_Pres_Low = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Baking_timer_max":
                            Varibale.Baking_Timer_max = Convert.ToInt32(dr["value"].ToString());
                            break;

                        case "totalAutoclav":
                            Varibale.totalAutoclav = Convert.ToInt32(dr["value"].ToString()) + 1;
                            break;

                        case "totalBaking":
                            Varibale.totalBaking = Convert.ToInt32(dr["value"].ToString()) + 1;
                            break;

                        case "Frig_1_Temp_High":
                            Varibale.Frig_Temp_High[1] = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Frig_1_Temp_Low":
                            Varibale.Frig_Temp_Low[1] = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Frig_2_Temp_High":
                            Varibale.Frig_Temp_High[2] = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Frig_2_Temp_Low":
                            Varibale.Frig_Temp_Low[2] = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Frig_3_Temp_High":
                            Varibale.Frig_Temp_High[3] = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Frig_3_Temp_Low":
                            Varibale.Frig_Temp_Low[3] = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Frig_4_Temp_High":
                            Varibale.Frig_Temp_High[4] = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Frig_4_Temp_Low":
                            Varibale.Frig_Temp_Low[4] = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Frig_5_Temp_High":
                            Varibale.Frig_Temp_High[5] = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Frig_5_Temp_Low":
                            Varibale.Frig_Temp_Low[5] = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Oil_Temp_High":
                            Varibale.Oil_Temp_High = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "Oil_Temp_Low":
                            Varibale.Oil_Temp_Low = Convert.ToDouble(dr["value"].ToString());
                            break;

                        case "portname1":
                            Varibale.portname1 = dr["value"].ToString();
                            break;

                        case "buadrate1":
                            Varibale.buadrate1 = Convert.ToInt32(dr["value"].ToString());
                            break;

                        case "parity1":
                            Varibale.parity1 = PublicMehotd.ConvertStringToParity(dr["value"].ToString());
                            break;

                        case "Frig_1_number":
                            Varibale.frig_number[1] = Convert.ToInt32(dr["value"].ToString());
                            break;

                        case "Frig_2_number":
                            Varibale.frig_number[2] = Convert.ToInt32(dr["value"].ToString());
                            break;

                        case "Frig_3_number":
                            Varibale.frig_number[3] = Convert.ToInt32(dr["value"].ToString());
                            break;

                        case "Frig_4_number":
                            Varibale.frig_number[4] = Convert.ToInt32(dr["value"].ToString());
                            break;

                        case "Frig_5_number":
                            Varibale.frig_number[5] = Convert.ToInt32(dr["value"].ToString());
                            break;


                        case "Oil_number":
                            Varibale.oil_number = Convert.ToInt32(dr["value"].ToString());
                            break;



                        case "save_count":
                            Varibale.Save_count = Convert.ToInt32(dr["value"].ToString());
                            break;

                        case "save_count_frig":
                            Varibale.Save_count_frig = Convert.ToInt32(dr["value"].ToString());
                            break;

                        case "save_count_baking_server":
                            Varibale.save_count_baking_server = Convert.ToInt32(dr["value"].ToString());
                            break;

                        case "save_count_autoclav_server":
                            Varibale.save_count_autoclav_server = Convert.ToInt32(dr["value"].ToString());
                            break;

                        case "port_counter":
                            Varibale.port_counter = dr["value"].ToString();
                            break;

                        case "zarin_product_ghabl":
                            Varibale.zarin.Add("zarin_product_ghabl", dr["value"].ToString());
                            break;

                        case "zarin_product_bad":
                            Varibale.zarin.Add("zarin_product_bad", dr["value"].ToString());
                            break;

                        case "brand_ghabl":
                            Varibale.zarin.Add("brand_ghabl", dr["value"].ToString());
                            break;

                        case "brand_bad":
                            Varibale.zarin.Add("brand_bad", dr["value"].ToString());
                            break;

                        case "vazn_ghabl":
                            Varibale.zarin.Add("vazn_ghabl", dr["value"].ToString());
                            break;

                        case "vazn_bad":
                            Varibale.zarin.Add("vazn_bad", dr["value"].ToString());
                            break;

                        case "baste_bandi_ghabl":
                            Varibale.zarin.Add("baste_bandi_ghabl", dr["value"].ToString());
                            break;

                        case "baste_bandi_bad":
                            Varibale.zarin.Add("baste_bandi_bad", dr["value"].ToString());
                            break;

                        case "darb_ghabl":
                            Varibale.zarin.Add("darb_ghabl", dr["value"].ToString());
                            break;

                        case "darb_bad":
                            Varibale.zarin.Add("darb_bad", dr["value"].ToString());
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        log_system.saveLogSystem(ex, "error read value =" + dr["value"].ToString());
                    }
                }

                cn.Close();
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.StackTrace);
                log_system.saveLogSystem(ex, "Variable Error ");
            }
        }
예제 #20
0
        private static string[] getLastDataCounter(int num)
        {
            string type = "";

            if (num == 1 || num == 2)
            {
                type = "ghabl";
            }
            else
            {
                type = "bad";
            }

            string zarin_product = ClassEnumProduct.getProductZarinNumber(Convert.ToInt64(Varibale.zarin["zarin_product_" + type])).ToString();


            string sql = "select * from zarin_report_counter where counter_num ='" + num
                         + "' and status = 'counts' "
                         + " and zarin_product = '" + zarin_product
                         + "' and brand = '" + Varibale.zarin["brand_" + type]
                         + "' and vazn = '" + Varibale.zarin["vazn_" + type]
                         + "' and darb = '" + Varibale.zarin["darb_" + type]
                         + "' and baste_bandi = '" + Varibale.zarin["baste_bandi_" + type] + "' ";

            try
            {
                string[]      x   = new string[10];
                SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(CommandType.Text, sql, cn);


                cn.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    x[0] = dr["id"].ToString();
                    x[1] = dr["counter_num"].ToString();
                    x[2] = dr["number"].ToString();
                    x[3] = dr["zarin_product"].ToString();
                    x[4] = dr["brand"].ToString();
                    x[5] = dr["darb"].ToString();
                    x[6] = dr["vazn"].ToString();
                    x[7] = dr["baste_bandi"].ToString();

                    // if (PublicMehotd.RetStringPersianCalender() == dr["datep"].ToString())
                    // {
                    cn.Close();
                    return(x);
                    // }
                    //else
                    //{
                    //    cn.Close();

                    //    return null;
                    // }
                }
                else
                {
                    cn.Close();
                    return(null);
                }
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "error get last data counter " + sql + " XX " + zarin_product);
                return(null);
            }
        }