Beispiel #1
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();
        }
Beispiel #2
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);
            }
        }