Esempio n. 1
0
        public ActionResult Index(Stocktaking st)
        {
            foreach (var i in db.Cleint)
            {
                if (i.AccountID == st.CleintID)
                {
                    st.CleintName = i.AccountName;
                    break;
                }
            }

            if (ModelState.IsValid)
            {
                if (st.OpeningDate == null)
                {
                    st.OpeningDate = DateTime.MinValue;
                }
                if (st.EndingDate == null)
                {
                    st.EndingDate = DateTime.MaxValue;
                }
                clc(st);
            }
            return(View(list));
        }
Esempio n. 2
0
 public bool UpdateStocktaking(Stocktaking temp)
 {
     try
     {
         using (SqlConnection _con = new SqlConnection(APIConstant.Instance._connectionString))
         {
             _con.Open();
             if (IsRemainInDB(temp.StocktakingID, _con))
             {
                 DeleteStocktaking(temp.StocktakingID);
                 InsertStocktaking(temp);
                 return(true);
             }
             else
             {
                 InsertStocktaking(temp);
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         LogFile.write("0", ex.Message);
         return(false);
     }
 }
Esempio n. 3
0
        public void clc(Stocktaking st)
        {
            foreach (var i in db.Product)
            {
                Stocktaking cur = new Stocktaking();
                cur.CleintID    = st.CleintID;
                cur.CleintName  = st.CleintName;
                cur.ProductID   = i.ProductID;
                cur.ProductName = i.Description;
                cur.Incoming    = Convert.ToDouble(i.Incoming);
                cur.Size        = i.Size;
                cur.OpeningDate = st.OpeningDate;
                cur.EndingDate  = st.EndingDate;
                foreach (var j in db2.Primission)
                {
                    if (j.ProductID == i.ProductID &&
                        j.Date >= cur.OpeningDate && j.Date <= cur.EndingDate)
                    {
                        cur.Outgoing += j.Outgoing;

                        if (j.ClientID == cur.CleintID)
                        {
                            cur.CleintOutgoing += j.Outgoing;
                        }
                    }
                }
                cur.Balance = cur.Incoming - cur.Outgoing;
                list.Add(cur);
            }
        }
Esempio n. 4
0
        public List <Stocktaking> SelectLikeRIconstruye(string search, int condition)
        {
            List <Stocktaking> listTemple  = new List <Stocktaking>();
            DataTable          selectTable = new DataTable();

            Stocktaking RefrenceExist = new Stocktaking();

            selectTable = RefrenceExist.SelectLikeRIconstruye(search, condition);

            if (condition == 1)
            {
                foreach (DataRow row in selectTable.Rows)
                {
                    listTemple.Add(new Stocktaking()
                    {
                        _CodigoBarrasIcontruye = row["CodigoItem"].ToString(), _DescripcionItem = row["descripcionItem"].ToString(), _nombreGrupo = row["NombreGr"].ToString(), _clasificacion = Int32.Parse(row["Clasif"].ToString())
                    });
                }
            }
            else if (condition == 2)
            {
                foreach (DataRow row in selectTable.Rows)
                {
                    listTemple.Add(new Stocktaking()
                    {
                        _CodigoBarrasIcontruye = row["CodigoItem"].ToString(), _DescripcionItem = row["descripcionItem"].ToString(), _nombreGrupo = row["NombreGr"].ToString()
                    });
                }
            }

            if (listTemple.Count == 0)
            {
                selectTable = RefrenceExist.SelectLikeRIconstruyeAll(search, condition);

                if (condition == 1)
                {
                    foreach (DataRow row in selectTable.Rows)
                    {
                        listTemple.Add(new Stocktaking()
                        {
                            _CodigoBarrasIcontruye = row["CodigoItem"].ToString(), _DescripcionItem = row["descripcion"].ToString(), _nombreGrupo = row["NombreGr"].ToString(), _clasificacion = Int32.Parse(row["Clasif"].ToString())
                        });
                    }
                }
                else if (condition == 2)
                {
                    foreach (DataRow row in selectTable.Rows)
                    {
                        listTemple.Add(new Stocktaking()
                        {
                            _CodigoBarrasIcontruye = row["CodigoItem"].ToString(), _DescripcionItem = row["descripcion"].ToString(), _nombreGrupo = row["NombreGr"].ToString()
                        });
                    }
                }
            }

            return(listTemple);
        }
Esempio n. 5
0
        public int InsertReference(string codigoUbicacion, string codigoBarras, string codigoBarrasIC, string descripcionItem, int id_Marca, int grupo, int cantidad, string imagen, string proyecto, string equivalencias, bool existe, string color)
        {
            int         actividades;
            Stocktaking insertR = new Stocktaking();

            actividades = insertR.InsertReference(codigoUbicacion, codigoBarras, codigoBarrasIC, descripcionItem, id_Marca, grupo, cantidad, imagen, proyecto, equivalencias, existe, color);

            return(actividades);
        }
Esempio n. 6
0
        public int Insertequivalences(string equivalencias, string codigoBarras)
        {
            int         actividades;
            Stocktaking insertR = new Stocktaking();

            actividades = insertR.Insertequivalences(equivalencias, codigoBarras);

            return(actividades);
        }
Esempio n. 7
0
        public ActionResult Index()
        {
            Stocktaking s = new Stocktaking();

            s.OpeningDate = DateTime.MinValue;
            s.EndingDate  = DateTime.MaxValue;
            clc(s);
            return(View(list));
        }
Esempio n. 8
0
        public int UpdateReference(string codigoUbicacion, string codigoBarras, string codigoBarrasIC, string descripcionItem, int id_Marca, int grupo, int cantidad, string imagen, string equivalencias, string color)
        {
            int         actividades;
            Stocktaking UpdateR = new Stocktaking();

            actividades = UpdateR.UpdateReference(codigoUbicacion, codigoBarras, codigoBarrasIC, descripcionItem, id_Marca, grupo, cantidad, imagen, equivalencias, color);

            return(actividades);
        }
Esempio n. 9
0
        public IHttpActionResult UpdateStocktaking(Stocktaking s)
        {
            bool returnValue = _db.UpdateStocktaking(s);

            if (returnValue)
            {
                return(new MyActionResult("S", HttpStatusCode.OK, Request));
            }
            else
            {
                return(new MyActionResult("F", HttpStatusCode.OK, Request));
            }
        }
Esempio n. 10
0
        public List <Stocktaking> GetMarcas()
        {
            List <Stocktaking> listTemple  = new List <Stocktaking>();
            DataTable          selectTable = new DataTable();

            Stocktaking Marcas = new Stocktaking();

            selectTable = Marcas.SelectMarca();

            foreach (DataRow row in selectTable.Rows)
            {
                listTemple.Add(new Stocktaking()
                {
                    _id_Marcas = Int32.Parse(row["id"].ToString()), _Marcas = row["marca"].ToString()
                });
            }

            return(listTemple);
        }
Esempio n. 11
0
        public List <Stocktaking> SelectLikeReference(string codBarras, string codUbicacion, int codProyecto)
        {
            List <Stocktaking> listTemple  = new List <Stocktaking>();
            DataTable          selectTable = new DataTable();

            Stocktaking RefrenceExist = new Stocktaking();

            selectTable = RefrenceExist.SelectLikeReference(codBarras, codUbicacion, codProyecto);

            foreach (DataRow row in selectTable.Rows)
            {
                listTemple.Add(new Stocktaking()
                {
                    _Ubicacion = row["codigoUbicacion"].ToString(), _Proyectos = row["DescripcióniContruye"].ToString(), _CodigoBarras = row["codigoBarras"].ToString(), _CodigoBarrasIcontruye = row["codigoBarrasIC"].ToString(), _DescripcionItem = row["descripcionItem"].ToString(), _Grupo = row["grupo"].ToString(), _Cantidad = Int32.Parse(row["cantidad"].ToString()), _Imagen = row["imagen"].ToString(), _Marcas = row["marca"].ToString(), _nombreGrupo = row["NombreGr"].ToString(), _Color = row["color"].ToString()
                });
            }

            return(listTemple);
        }
Esempio n. 12
0
        public List <Stocktaking> selectProyectos()
        {
            List <Stocktaking> listTemple  = new List <Stocktaking>();
            DataTable          selectTable = new DataTable();

            Stocktaking Projects = new Stocktaking();

            selectTable = Projects.selectProyectos();

            foreach (DataRow row in selectTable.Rows)
            {
                listTemple.Add(new Stocktaking()
                {
                    _codProyectos = row["CodCCiConstruye"].ToString(), _Proyectos = row["DescripcióniContruye"].ToString()
                });
            }

            return(listTemple);
        }
Esempio n. 13
0
        public List <Stocktaking> SelectLikeLocationItem(string codBarrasLocation)
        {
            List <Stocktaking> listTemple  = new List <Stocktaking>();
            DataTable          selectTable = new DataTable();

            Stocktaking LocationExist = new Stocktaking();

            selectTable = LocationExist.SelectLikeLocationItem(codBarrasLocation);

            foreach (DataRow row in selectTable.Rows)
            {
                listTemple.Add(new Stocktaking()
                {
                    _Ubicacion = row["codigoUbicacion"].ToString()
                });
            }

            return(listTemple);
        }
Esempio n. 14
0
        public List <Stocktaking> SelectLikeReferenceCod(string codBarras)
        {
            List <Stocktaking> listTemple  = new List <Stocktaking>();
            DataTable          selectTable = new DataTable();

            Stocktaking RefrenceExist = new Stocktaking();

            selectTable = RefrenceExist.SelectLikeReferenceCod(codBarras);

            foreach (DataRow row in selectTable.Rows)
            {
                listTemple.Add(new Stocktaking()
                {
                    _CodigoBarras = row["codigoBarras"].ToString(), _CodigoBarrasIcontruye = row["codigoBarrasIC"].ToString(), _DescripcionItem = row["descripcionItem"].ToString(), _Grupo = row["grupo"].ToString(), _Imagen = row["imagen"].ToString(), _Marcas = row["marca"].ToString(), _nombreGrupo = row["NombreGr"].ToString(), _Color = row["color"].ToString()
                });
            }

            return(listTemple);
        }
Esempio n. 15
0
        public List <Stocktaking> selectEquivalences(string codBarras)
        {
            List <Stocktaking> listTemple  = new List <Stocktaking>();
            DataTable          selectTable = new DataTable();

            Stocktaking equivalences = new Stocktaking();

            selectTable = equivalences.selectEquivalences(codBarras);

            foreach (DataRow row in selectTable.Rows)
            {
                listTemple.Add(new Stocktaking()
                {
                    _Equivalencia = row["codigoItem"].ToString()
                });
            }

            return(listTemple);
        }
Esempio n. 16
0
        public List <Stocktaking> GetGrupos()
        {
            List <Stocktaking> listTemple  = new List <Stocktaking>();
            DataTable          selectTable = new DataTable();

            Stocktaking grupos = new Stocktaking();

            selectTable = grupos.SelectGrupo();

            foreach (DataRow row in selectTable.Rows)
            {
                listTemple.Add(new Stocktaking()
                {
                    _clasificacion = Int32.Parse(row["Clsif"].ToString()), _nombreGrupo = row["NombreGr"].ToString()
                });
            }

            return(listTemple);
        }
Esempio n. 17
0
        public List <Stocktaking> GetAllStocktaking()
        {
            try
            {
                using (SqlConnection _con = new SqlConnection(APIConstant.Instance._connectionString))
                {
                    _con.Open();
                    string     query = "SELECT TOP 5 * FROM tmpHHTStocktaking";
                    SqlCommand cmd   = new SqlCommand(query, _con);
                    cmd.CommandType = CommandType.Text;
                    SqlDataReader reader = cmd.ExecuteReader();

                    List <Stocktaking> returnList = new List <Stocktaking>();
                    while (reader.Read())
                    {
                        Stocktaking temp = new Stocktaking();
                        temp.StocktakingID  = reader.IsDBNull(0) ? null : reader.GetString(0);
                        temp.ScanMode       = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                        temp.LocationCode   = reader.IsDBNull(2) ? null : reader.GetString(2);
                        temp.Barcode        = reader.IsDBNull(3) ? null : reader.GetString(3);
                        temp.Quantity       = reader.IsDBNull(4) ? 0 : reader.GetDecimal(4);
                        temp.UnitCode       = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
                        temp.Flag           = reader.IsDBNull(7) ? null : reader.GetString(7);
                        temp.Description    = reader.IsDBNull(8) ? null : reader.GetString(8);
                        temp.SKUCode        = reader.IsDBNull(9) ? null : reader.GetString(9);
                        temp.ExBarcode      = reader.IsDBNull(10) ? null : reader.GetString(10);
                        temp.InBarcode      = reader.IsDBNull(11) ? null : reader.GetString(11);
                        temp.SKUMode        = reader.IsDBNull(12) ? false : reader.GetBoolean(12);
                        temp.HHTName        = reader.IsDBNull(13) ? null : reader.GetString(13);
                        temp.DepartmentCode = reader.IsDBNull(15) ? null : reader.GetString(15);

                        returnList.Add(temp);
                    }
                    return(returnList);
                }
            }
            catch (Exception ex)
            {
                LogFile.write("0", ex.Message);
                return(null);
            }
        }
Esempio n. 18
0
        public List <Stocktaking> getLocation(string codBarras)
        {
            List <Stocktaking> listTemple  = new List <Stocktaking>();
            DataTable          selectTable = new DataTable();

            Stocktaking locations = new Stocktaking();

            selectTable = locations.getLocation(codBarras);

            foreach (DataRow row in selectTable.Rows)
            {
                listTemple.Add(new Stocktaking()
                {
                    _Ubicacion = row["codigoUbicacion"].ToString(), _Cantidad = Int32.Parse(row["cantidad"].ToString())
                });
            }

            return(listTemple);
            //select codigoUbicacion from NUbicacionXReferenciaCB where codigoBarras = + codBarras +
        }
Esempio n. 19
0
        public bool InsertStocktaking(Stocktaking temp)
        {
            try
            {
                using (SqlConnection _con = new SqlConnection(APIConstant.Instance._connectionString))
                {
                    _con.Open();

                    SqlCommand _insert_command = new SqlCommand(APIConstant.Instance._insert_query, _con);
                    _insert_command.CommandType = CommandType.Text;

                    DateTime currentDT = DateTime.Now;

                    _insert_command.Parameters.Clear();
                    foreach (PropertyInfo propertyInfo in temp.GetType().GetProperties(APIConstant.Instance.flags))
                    {
                        if (propertyInfo.GetValue(temp, null) == null)
                        {
                            _insert_command.Parameters.AddWithValue("@" + propertyInfo.Name, DBNull.Value);
                        }
                        else
                        {
                            _insert_command.Parameters.AddWithValue("@" + propertyInfo.Name, propertyInfo.GetValue(temp, null));
                        }
                    }

                    //Random rand = new Random();
                    //string uniqueID = currentDT.ToString("yy") + currentDT.ToString("MM") + currentDT.ToString("dd") + "999" + rand.Next(0, 10000000).ToString().PadLeft(7, '0');

                    //_insert_command.Parameters.AddWithValue("@StocktakingID", temp.StocktakingID);
                    //_insert_command.Parameters.AddWithValue("@ScanMode", temp.ScanMode);
                    //_insert_command.Parameters.AddWithValue("@LocationCode", temp.LocationCode);
                    //_insert_command.Parameters.AddWithValue("@Barcode", temp.Barcode);
                    //_insert_command.Parameters.AddWithValue("@Quantity", temp.Quantity);
                    _insert_command.Parameters.AddWithValue("@NewQuantity", DBNull.Value);
                    //_insert_command.Parameters.AddWithValue("@Unitcode", temp.UnitCode);
                    //_insert_command.Parameters.AddWithValue("@Flag", temp.Flag);
                    //_insert_command.Parameters.AddWithValue("@Description", temp.Description);
                    //_insert_command.Parameters.AddWithValue("@SKUCode", temp.SKUCode);
                    //_insert_command.Parameters.AddWithValue("@ExBarcode", temp.ExBarcode);
                    //_insert_command.Parameters.AddWithValue("@InBarcode", temp.InBarcode);
                    //_insert_command.Parameters.AddWithValue("@SKUMode", temp.SKUMode);
                    //_insert_command.Parameters.AddWithValue("@HHTName", temp.HHTName);
                    _insert_command.Parameters.AddWithValue("@CountDate", APIConstant.Instance._countDate);
                    //_insert_command.Parameters.AddWithValue("@DepartmentCode", temp.DepartmentCode);
                    _insert_command.Parameters.AddWithValue("@FileName", "");
                    _insert_command.Parameters.AddWithValue("@FlagImport", false);
                    //_insert_command.Parameters.AddWithValue("@HHTID", temp.HHTID);
                    _insert_command.Parameters.AddWithValue("@CreateDate", currentDT);
                    //_insert_command.Parameters.AddWithValue("@CreateBy", temp.Username);
                    _insert_command.Parameters.AddWithValue("@UpdateDate", currentDT);
                    //_insert_command.Parameters.AddWithValue("@UpdateBy", temp.Username);
                    _insert_command.Parameters.AddWithValue("@ImportDate", currentDT);

                    _insert_command.ExecuteNonQuery();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogFile.write("0", ex.Message);
                return(false);
            }
        }
Esempio n. 20
0
        private bool SendRequest(StockTakingModel item, int mode)
        {
            bool returnValue = true;

            try
            {
                req             = (HttpWebRequest)WebRequest.Create(@"http://" + DatabaseModule.Instance.FtpServer + ":15267/api/stocktakings/InsertStocktaking");
                req.ContentType = "application/json";
                req.Method      = "POST";
                req.AllowWriteStreamBuffering = true;
                req.Proxy = null;

                Stocktaking s = new Stocktaking
                {
                    StocktakingID  = item.StocktakingID,
                    ScanMode       = item.ScanMode,
                    Barcode        = item.Barcode,
                    LocationCode   = item.LocationCode,
                    Quantity       = item.Quantity,
                    UnitCode       = item.UnitCode,
                    Flag           = item.Flag,
                    Description    = item.Description,
                    SKUCode        = item.SKUCode,
                    ExBarcode      = item.ExBarcode,
                    InBarcode      = item.InBarcode,
                    SKUMode        = item.SKUMode,
                    HHTName        = DatabaseModule.Instance.HHTName,
                    HHTID          = DatabaseModule.Instance.HHTID,
                    DepartmentCode = string.IsNullOrEmpty(item.DepartmentCode) ? DatabaseModule.Instance.currentDepartmentCode : item.DepartmentCode,
                    CreateBy       = DatabaseModule.Instance.currentUser,
                    UpdateBy       = DatabaseModule.Instance.currentUser
                };
                string pJson = JsonConvert.SerializeObject(s);
                //req.ContentLength = encoding.GetBytes(pJson).Length;
                writer = new StreamWriter(req.GetRequestStream());
                writer.Write(pJson);
                writer.Flush();
                writer.Close();

                res    = (HttpWebResponse)req.GetResponse();
                reader = new StreamReader(res.GetResponseStream());
                string responseMessage = reader.ReadToEnd();
                reader.Close();

                if ("F".Equals(responseMessage))
                {
                    throw new APIException("Server cant commit transfered-data to database, please check the server-side.");
                }

                item.SendFlag = true;
            }
            catch (APIException ex)
            {
                item.SendFlag = false;
                loading.ShowMessageLoading(ex.Message);
                returnValue = false;
            }
            catch (Exception ex)
            {
                item.SendFlag = false;
                loading.ShowMessageLoading("The process cant transfer realtime data to server.");
                returnValue = false;
            }

            DatabaseModule.Instance.QueryInsertFromScan(item, mode);
            return(returnValue);
        }