Exemple #1
0
        /// <summary>
        /// Add record to database using object.
        /// </summary>
        /// <param name="prodObj"></param>
        /// <returns></returns>
        public bool AddRecord(CProductDetail prodObj)
        {
            DataRow row    = m_LocalDatabase.AddRow(prodObj);
            bool    result = m_Database.AddRecord(constproductTableName, row);

            return(result);
        }
Exemple #2
0
        /// <summary>
        ///  Update record to database.
        /// </summary>
        /// <param name="prodObj"></param>
        /// <returns></returns>
        // SQL Query to Update
        // "UPDATE ProductDetail SET ProductName = 'XYZ',ProductWeight = '150 kg',ActualProductWeight = '120 kg',Scale = 2,DateTime ='11/9/2017 1:23 PM' WHERE RecordNo =1"
        public bool UpdateProducttable(CProductDetail prodObj)
        {
            string query = string.Format("UPDATE {0} SET ProductName = '{1}',ProductWeight = '{2}',ActualProductWeight = '{3}',Scale = {4} WHERE RecordNo ={5}", constProductDetailTableName, prodObj.ProductName, prodObj.ProductWeight, prodObj.ActualProductWeight, prodObj.Scale, prodObj.ProductNumber);

            try
            {
                if (m_SqlConnection == null)
                {
                    m_SqlConnection = new SqlCeConnection(GetConnectionString(constProductDetailTableName));
                }

                if (m_SqlConnection.State == ConnectionState.Broken || m_SqlConnection.State == ConnectionState.Closed)
                {
                    m_SqlConnection.Open();
                }
            }
            catch (Exception ex)
            {
#if DEBUG
                System.Diagnostics.Debug.WriteLine(ex.StackTrace);
                return(false);
#endif
            }
            return(ExecuteQuery(query));
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="prodObj"></param>
        /// <returns></returns>
        public DataRow AddRow(CProductDetail prodObj)
        {
            DataRow dr = m_ProductDetailDataTable.NewRow();

            dr["RecordNo"]            = prodObj.ProductNumber;
            dr["ProductName"]         = prodObj.ProductName;
            dr["ProductWeight"]       = prodObj.ProductWeight;
            dr["ActualProductWeight"] = prodObj.ActualProductWeight;
            dr["Scale"] = prodObj.Scale;
            m_ProductDetailDataTable.Rows.Add(dr);
            return(dr);
        }
Exemple #4
0
        private CProductDetail ReadValue(DataRow row)
        {
            CProductDetail prodObj = new CProductDetail();

            if (row != null)
            {
                prodObj.ProductNumber       = Convert.ToInt32(row["RecordNo"].ToString());
                prodObj.ProductName         = row["ProductName"].ToString();
                prodObj.ProductWeight       = row["ProductWeight"].ToString();
                prodObj.ActualProductWeight = row["ActualProductWeight"].ToString();
                prodObj.Scale = Convert.ToByte(row["Scale"].ToString());
            }
            return(prodObj);
        }
Exemple #5
0
        /// <summary>
        ///  update record to database.
        /// </summary>
        /// <param name="prodObj"></param>
        /// <returns></returns>
        public bool UpdateRecord(CProductDetail prodObj)
        {
            bool result = m_LocalDatabase.UpdateProducttable(prodObj);

            return(result);
        }