コード例 #1
0
        public ActionResult StockDet(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(View());
            }
            else
            {
                string sSQL = " SELECT * FROM icstk " +
                              "where AUTOINC ='" + id + "'";
                using (MySqlDataReader reader = conn2.ExecuteReader(sSQL))
                {
                    if (reader.Read()) // If you're expecting more than one line, change this to while(reader.Read()).
                    {
                        ICModel rec = new ICModel
                        {
                            STKCODE = reader["STKCODE"].ToString(),
                            PART    = reader["PART"].ToString(),
                            DT_EDIT = reader["DT_EDIT"].ToString(),
                        };

                        ViewBag.FieldValue = rec;
                        return(View());
                    }
                }
            }

            return(View());
        }
コード例 #2
0
        public ActionResult LocationDet(string id, ICModel viewModel)
        {
            if (id == "Save")
            {
                sSQL = " SELECT * FROM icloc where LOC_CODE ='" + viewModel.LOC_CODE + "'";
                using (MySqlDataReader reader = conn2.ExecuteReader(sSQL))
                {
                    if (reader.Read())
                    {
                        return(Json(new { status = "fail", message = "Location Code already exists", fieldname = "LOC_CODE" }));
                    }
                    else
                    {
                        sSQL = " INSERT into icloc" +
                               " (LOC_CODE, LOC_PART, EDIT_ID,DT_EDIT,CREATE_ID,DT_CREATE)" +
                               " values ( " +
                               viewModel.LOC_CODE + " , " +
                               viewModel.LOC_PART + " , " +
                               Session["USER_ID"] + " , " +
                               DateTime.Now + " , " +
                               Session["USER_ID"] + " , " +
                               DateTime.Now + " ) ";

                        conn2.ExecuteQuery(sSQL);
                        conn2.Close();

                        return(Json(new { status = "saved", message = viewModel.LOC_CODE }));
                    }
                }
            }
            else if (id == "Update")
            {
                sSQL = " UPDATE icloc set" +
                       " LOC_PART= " + viewModel.LOC_PART + " , " +
                       " EDIT_ID= " + Session["USER_ID"] + " , " +
                       " DT_EDIT= " + DateTime.Now +
                       " WHERE LOC_CODE = " + viewModel.LOC_CODE;

                conn2.ExecuteQuery(sSQL);
                conn2.Close();

                return(Json(new { status = "updated", message = viewModel.LOC_CODE }));
            }
            else
            {
                sSQL = " DELETE FROM icloc" +
                       " WHERE LOC_CODE = " + viewModel.LOC_CODE;

                conn2.ExecuteQuery(sSQL);
                conn2.Close();

                return(Json(new { status = "deleted", message = viewModel.LOC_CODE }));
            }
        }
コード例 #3
0
        public ActionResult CurrencyDet(string id, string tableName)
        {
            TABLENAME = tableName;

            if (TABLENAME == "arcurr")
            {
                ViewBag.Title = "Debtor Currency Details";
            }
            else
            {
                ViewBag.Title = "Vendor Currency Details";
                //ViewBag.sDebOrVen = "Ven";
            }

            if (string.IsNullOrEmpty(id))
            {
                return(View());
            }
            else
            {
                sSQL = " SELECT * FROM " + TABLENAME +
                       "where AUTOINC ='" + id + "'";
                using (MySqlDataReader reader = conn2.ExecuteReader(sSQL))
                {
                    if (reader.Read()) // If you're expecting more than one line, change this to while(reader.Read()).
                    {
                        ICModel rec = new ICModel
                        {
                            CURR_CODE = reader["CURR_CODE"].ToString(),
                            CURR_PART = reader["CURR_PART"].ToString(),
                            RATE      = reader["CURR_PART"].ToString(),
                            DT_EDIT   = reader["DT_EDIT"].ToString(),
                        };

                        ViewBag.FieldValue = rec;
                        return(View());
                    }
                }
            }

            return(View());
        }
コード例 #4
0
        public ActionResult CurrencyDet(string id, ICModel viewModel)
        //public ActionResult CurrencyDet(string id, string sTableName, ICModel viewModel)
        {
            string sDebOrVen;

            if (TABLENAME == "arcurr")
            {
                sDebOrVen = "Deb";
            }
            else
            {
                sDebOrVen = "Ven";
            }

            if (id == "Save")
            {
                sSQL = " SELECT * FROM " + TABLENAME +
                       " where CURR_CODE ='" + viewModel.CURR_CODE + "'";
                using (MySqlDataReader reader = conn2.ExecuteReader(sSQL))
                {
                    if (reader.Read())
                    {
                        return(Json(new { status = "fail", message = "Currency Code already exists", fieldname = "CURR_CODE" }));
                    }
                    else
                    {
                        sSQL = " INSERT into " + TABLENAME +
                               " (CURR_CODE, CURR_PART, RATE, EDIT_ID,DT_EDIT,CREATE_ID,DT_CREATE)" +
                               " values " +
                               viewModel.CURR_CODE + " , " +
                               viewModel.CURR_PART + " , " +
                               Session["USER_ID"] + " , " +
                               DateTime.Now + " , " +
                               Session["USER_ID"] + " , " +
                               DateTime.Now + " ) ";

                        conn2.ExecuteQuery(sSQL);
                        conn2.Close();

                        return(Json(new { status = "saved", message = viewModel.CURR_CODE, DebOrVen = sDebOrVen }));
                    }
                }
            }
            else if (id == "Update")
            {
                sSQL = " UPDATE " + TABLENAME + " set" +
                       " CURR_PART= " + viewModel.CURR_PART + " , " +
                       " RATE= " + viewModel.RATE + " , " +
                       " EDIT_ID= " + Session["USER_ID"] + " , " +
                       " DT_EDIT= " + DateTime.Now +
                       " WHERE CURR_CODE = " + viewModel.CURR_CODE;

                conn2.ExecuteQuery(sSQL);
                conn2.Close();

                return(Json(new { status = "updated", message = viewModel.CURR_CODE, DebOrVen = sDebOrVen }));
            }
            else
            {
                sSQL = " DELETE from " + TABLENAME +
                       " WHERE CURR_CODE = " + viewModel.CURR_CODE;

                conn2.ExecuteQuery(sSQL);
                conn2.Close();

                return(Json(new { status = "deleted", message = viewModel.CURR_CODE, DebOrVen = sDebOrVen }));
            }
        }