对于许多企业来说,进销存管理是其最基本的经营活动之一。然而,由于管理不当,许多企业都会面临存货过多或过少、设备闲置、经营效益较低等问题。为了解决这些问题,许多企业开始使用进销存软件进行管理。这篇文章将介绍一款名为“进销存软件”的开源软件,并提供其源代码示例。
关于进销存软件
进销存软件是一种管理库存和销售价格的软件。该软件可以帮助用户轻松地管理库存、过期商品、特价等信息。此外,它还可以帮助用户制定销售计划、了解库存情况、预测销售和利润等等。下面是进销存软件的基本源码示例。源码中包括库存管理、销售管理、商品管理、销售价格管理和数据分析等五个功能模块的实现。
进销存源码演示:c.csymzs.top
部分源码展示:generic.py
# coding=utf-8
__author__ = 'zhugl'
# created at 15-4-21
import datetime
import xlwt
import re
from django.db import models
from django.db import connectionconnection,transaction
from django.db.models import fields
from django.db.models.fields import related
from django.contrib import admin
from django.http import HttpRequest,HttpResponseRedirect,HttpResponse
from django.contrib.contenttypes.modelsmodels import ContentType
from django.utils.text import force_textforce_text
from django.utils.encoding import smart_str
from django.utils.http import urlquote
from django.utils.translation import ugettext_lazyugettext_lazy as _
from common import const
from midware import cusercuser
def update(sql, params=None):
"""
:param sql:
:param params:
:return:
"""
cursor = connection.cursor()
with transaction.atomic():
try:
if params:
cursor.execute(sql,params)
else:
cursor.execute(sql)
except Exception,e:
print e
def get_app_model_info_from_request(request):
"""
"""
if request and isinstance(request,HttpRequest):
import re
pattern = re.compile(r"/(admin)/(\w+)/(\w+)/(\d+)")
match = pattern.match(request.path)
if match and match.group():
app = match.group(2)
model = match.group(3)
oid = match.group(4)
ct = ContentType.objects.get(app_label=app,model=model)
obj = ct.get_object_for_this_type(id=oid)
return {'app':app,'model':model,'id':oid,'obj':obj}
return None
class MineBOManager(models.Manager):
"""
get the objects created by current login user
"""
def get_query_set(self):
return super(MineBOManager,self).get_query_set().filter(creator=cuser.getuser())
class BOManager(models.Manager):
"""
"""
def get_query_set(self):
return super(BOManager,self).get_query_set()
class BO(models.Model):
"""
All business object derive from this class
"""
begin = models.DateField(_('begin date'),blank=True,null=True)
end = models.DateField(_('end date'),blank=True,null=True)
creator = models.CharField(_("creator"),blank=True,null=True,max_length=const.DB_CHAR_NAME_20)
modifier = models.CharField(_("modifier"),blank=True,null=True,max_length=const.DB_CHAR_NAME_20)
creation = models.DateTimeField(_('creation'),auto_now_add=True,blank=True,null=True)
modification = models.DateTimeField(_('modification'),auto_now=True,blank=True,null=True)
# mine = MineBOManager()
objects = models.Manager()
def __unicode__(self):
display = getattr(self,'name',None) or getattr(self,'title',None) or getattr(self,'description',None)
if not display:
display = ' '
return u'%s' % display
class Meta:
abstract = True
class BOAdmin(admin.ModelAdmin):
"""
All business object admin derive from this class
"""
CODE_NUMBER_WIDTH = 4
CODE_PREFIX = '9'
extra_buttons = []
exclude = ['creator','modifier','creation','modification','begin','end']
list_per_page = 18
actions = ['export_selected_data']
def changeform_view(self, request, object_id=None, form_url='', extra_context=None):
"""
:param request:
:param object_id:
:param form_url:
:param extra_context:
:return:
"""
app_info = get_app_model_info_from_request(request)
workflow_modal = None
workflow_instance = None
has_workflow_modal = False
has_workflow_instance = False
show_workflow_line = False
show_submit_button = False
can_restart = False
can_edit = False
# print app_info
if app_info:
try:
modal = ContentType.objects.get(app_label='workflow',model='modal')
workflow_modal = modal.get_object_for_this_type(app_name=app_info['app'],model_name=app_info['model'])
has_workflow_modal = True
# print workflow_modal.code
instance = ContentType.objects.get(app_label='workflow',model='instance')
workflow_instance = instance.get_object_for_this_type(modal=workflow_modal,object_id=app_info['id'])
has_workflow_instance = True
todo = ContentType.objects.get(app_label='workflow',model='todolist')
todo_list = todo.model_class().objects.filter(inst=workflow_instance,status=0,user=request.user)
x = todo_list.all()
if x and len(x)>0:
can_edit = x[0].node.can_edit
if todo_list.count() > 0:
# print 'we fount it'
unread = todo_list.filter(is_read=0)
show_workflow_line = True
if unread.count() > 0:
unread.update(is_read=1,read_time=datetime.datetime.now())
if workflow_instance.status == 3 and request.user == workflow_instance.starter:
can_restart = True
show_workflow_line = True
except Exception,e:
print Exception,e
if workflow_modal and not workflow_instance:
show_submit_button = True
extra_context = extra_context or {}
ctx = dict(
has_workflow_instance = has_workflow_instance,
has_workflow_modal = has_workflow_modal,
workflow_modal = workflow_modal,
workflow_instance = workflow_instance,
show_workflow_line = show_workflow_line,
can_restart = can_restart,
can_edit = can_edit,
show_submit_button = show_submit_button,
)
if len(self.extra_buttons) > 0:
buttons = dict(
extra_buttons = self.extra_buttons
)
ctx.update(buttons)
extra_context.update(ctx)
# print extra_context
return super(BOAdmin,self).changeform_view(request,object_id,form_url,extra_context)
def history_view(self, request, object_id, extra_context=None):
"""
:param request:
:param object_id:
:param extra_context:
:return:
"""
app_info = get_app_model_info_from_request(request)
# print app_info
if app_info:
try:
modal = ContentType.objects.get(app_label='workflow',model='modal')
workflow_modal = modal.get_object_for_this_type(app_name=app_info['app'],model_name=app_info['model'])
has_workflow_modal = True
instance = ContentType.objects.get(app_label='workflow',model='instance')
workflow_instance = instance.get_object_for_this_type(modal=workflow_modal,object_id=app_info['id'])
has_workflow_instance = True
history = ContentType.objects.get(app_label='workflow',model='history')
history_list = history.model_class().objects.filter(inst=workflow_instance)
has_history = True
todo = ContentType.objects.get(app_label='workflow',model='todolist')
todo_list = todo.model_class().objects.filter(inst=workflow_instance,status=0).exclude(node=None)
extra_context = extra_context or {}
ctx = dict(
has_workflow_instance = has_workflow_instance,
has_workflow_modal = has_workflow_modal,
workflow_modal = workflow_modal,
workflow_instance = workflow_instance,
history_list = history_list,
has_history = has_history,
todo_list = todo_list,
)
# print history_list
extra_context.update(ctx)
except Exception,e:
print Exception,e
pass
return super(BOAdmin,self).history_view(request,object_id,extra_context)
def get_changeform_initial_data(self, request):
import datetime
return {'begin':datetime.date.today,'end':datetime.date(9999,12,31)}
def save_model(self, request, obj, form, change):
if change:
setattr(obj,'modifier',request.user.username)
else:
setattr(obj,'creator',request.user.username)
setattr(obj,'begin',datetime.date.today())
setattr(obj,'end',datetime.date(9999,12,31))
try:
setattr(obj,'user',request.user)
except Exception,e:
pass
super(BOAdmin,self).save_model(request,obj,form,change)
# print '=========it is here========='
try:
code = getattr(obj,'code')
# print code
if code is None or len(code) == 0:
fmt = '%s%0'+str(self.CODE_NUMBER_WIDTH)+'d'
code = fmt % (self.CODE_PREFIX,obj.id)
table = obj._meta.db_table
sql = 'update %s set code = \'%s\' where id=%s' % (table,code,obj.id)
print sql
update(sql)
except Exception,e:
print e
# def response_change(self, request, obj):
# return HttpResponseRedirect('')
def export_selected_data(self,request,queryset):
ops = self.model._meta
workbook = xlwt.Workbook(encoding='utf-8')
dd = datetime.date.today().strftime('%Y%m%d')
file_name = force_text(ops.verbose_name+dd)
sheet = workbook.add_sheet(force_text(ops.verbose_name))
obj_fields = getattr(self,'export_fields',None) or self.list_display or self.fields
head_col_index = 0
for field in obj_fields:
col_name = field
try:
f = ops.get_field(field)
col_name = f.verbose_name
except Exception,e:
f = getattr(self.model,field)
if hasattr(f,'short_description'):
col_name = f.short_description
sheet.write(0,head_col_index,force_text(col_name))
head_col_index+=1
row_index = 1
for obj in queryset:
col_index = 0
for field in obj_fields:
f = field
try:
f = ops.get_field(field)
except Exception,e:
pass
v = getattr(obj,field,'')
if hasattr(v,'__call__') or callable(v):
v = v()
elif type(f) == fields.DateField:
v = v.strftime('%Y-%m-%d')
elif type(f) == fields.DateTimeField:
v = v.strftime('%Y-%m-%d %H:%M')
elif type(f) == fields.CharField and f.choices:
fc = 'get_'+field+'_display'
v = getattr(obj,fc)()
elif type(f) == related.ForeignKey:
v = str(v)
sheet.write(row_index,col_index,v)
col_index += 1
row_index += 1
response = HttpResponse(content_type='application/vnd.ms-excel')
agent = request.META.get('HTTP_USER_AGENT')
nn = smart_str(file_name)
if agent and re.search('MSIE',agent):
nn = urlquote(file_name)
response['Content-Disposition'] = 'attachment; filename=%s.xls'%nn
workbook.save(response)
return response
#self.message_user(request,'SUCCESS')
export_selected_data.short_description = _("export selected %(verbose_name_plural)s")
class Meta:
ordering = ['-creation']
class Media:
css = {'all':('css/maximus.css',)}
js = ('js/maximus.js',)
库存管理:
#include <iostream>
using namespace std;
class Stock {
public:
string stockID; //商品ID
string stockName; //商品名称
int stockNum; //商品数量
double stockPrice; //商品价格
void input();
void output();
};
void Stock::input() {
cout << "请输入商品ID:";
cin >> stockID;
cout << "请输入商品名称:" ;
cin >> stockName;
cout << "请输入商品数量:";
cin >> stockNum;
cout << "请输入商品价格:";
cin >> stockPrice;
}
void Stock::output() {
cout << "商品ID:" << stockID << endl;
cout << "商品名称:" << stockName << endl;
cout << "商品数量:" << stockNum << endl;
cout << "商品价格:" << stockPrice << endl;
}
int main() {
Stock stock;
stock.input();
stock.output();
return 0;
}
销售管理:
#include<iostream>
#include<string>
using namespace std;
class Sale {
public:
string saleID; //销售编号
string saleName; //客户姓名
string saleAddress; //客户地址
string salePhone; //客户电话
double salePrice; //销售价格
void input();
void output();
};
void Sale::input() {
cout << "请输入销售编号:";
cin >> saleID;
cout << "请输入客户名称:";
cin >> saleName;
cout << "请输入客户地址:";
cin >> saleAddress;
cout << "请输入客户电话:";
cin >> salePhone;
cout << "请输入销售价格:";
cin >> salePrice;
}
void Sale::output() {
cout << "销售编号:" << saleID << endl;
cout << "客户姓名:" << saleName << endl;
cout << "客户地址:" << saleAddress << endl;
cout << "客户电话:" << salePhone << endl;
cout << "销售价格:" << salePrice << endl;
}
int main() {
Sale sale;
sale.input();
sale.output();
return 0;
}
商品管理:
#include<iostream>
#include<string>
using namespace std;
class Goods {
public:
string goodsID; //商品编号
string goodsName; //商品名称
string goodsType; //商品类型
double goodsPrice; //商品价格
void input();
void output();
};
void Goods::input() {
cout << "请输入商品编号:";
cin >> goodsID;
cout << "请输入商品名称:";
cin >> goodsName;
cout << "请输入商品类型:";
cin >> goodsType;
cout << "请输入商品价格:";
cin >> goodsPrice;
}
void Goods::output() {
cout << "商品编号:" << goodsID << endl;
cout << "商品名称:" << goodsName << endl;
cout << "商品类型:" << goodsType << endl;
cout << "商品价格:" << goodsPrice << endl;
}
int main() {
Goods goods;
goods.input();
goods.output();
return 0;
}
销售价格管理:
#include<iostream>
#include<string>
using namespace std;
class SalePrice {
public:
string goodsID; //商品编号
double goodsPrice; //商品价格
void input();
void output();
};
void SalePrice::input() {
cout << "请输入商品编号:";
cin >> goodsID;
cout << "请输入商品价格:";
cin >> goodsPrice;
}
void SalePrice::output() {
cout << "商品编号:" << goodsID << endl;
cout << "商品价格:" << goodsPrice << endl;
}
int main() {
SalePrice salePrice;
salePrice.input();
salePrice.output();
return 0;
}
数据分析:
#include<iostream>
#include<string>
using namespace std;
class DataAnalysis {
public:
string goodsID; //商品编号
double salePrice; //销售价格
void input();
void output();
};
void DataAnalysis::input() {
cout << "请输入商品编号:";
cin >> goodsID;
cout << "请输入销售价格:";
cin >> salePrice;
}
void DataAnalysis::output() {
cout << "商品编号:" << goodsID << endl;
cout << "销售价格:" << salePrice << endl;
}
int main() {
DataAnalysis dataAnalysis;
dataAnalysis.input();
dataAnalysis.output();
return 0;
}
进销存软件的功能及用途
1. 库存管理
库存管理是进销存软件最基本的功能之一。用户可以通过该功能实时了解库存量和货品状况,从而帮助企业及时发现库存异常问题,及时采取相关措施进行处理,保证库存货物的安全和准确性。
2. 销售管理
这项功能帮助用户快速定位顾客信息(顾客姓名、手机号码、地址等等),能够让用户更容易地管理顾客,提高与顾客的互动效率,帮助企业带来更高的销售收入。
3. 商品管理
商品管理是一个企业的重要部分。进销存软件允许用户添加新的商品,更新现有商品信息,以及查看商品发展历史。同时,该软件也可以让用户更好地了解商品的使用状况、品质问题、过期时间等。
4. 销售价格管理
通过这项功能,目标定位的良好的企业能够更好地了解客户的需求和消费习惯,避免因价格过高而失去消费者,同时目标定位不好的企业也能够迅速地调整销售价格,以达到利润最大化。
5. 数据分析
数据分析可以帮助企业及时了解销售和库存数据,优化生产和销售计划,进一步提高销售业绩并增加利润。数据分析通过直观的图表和图形展示,使企业更好地了解其经营情况和数据变化趋势,并及时进行决策调整。
小结
本文介绍了进销存软件的功能和应用,并提供了该软件的源代码示例。通过这些功能模块,进销存软件可以帮助企业更好地进行进销存管理。当然,每个企业的经营情况不同,需要根据实际情况进行选择和调整。因此,在使用进销存软件时,需要结合实际需求进行使用和管理。同时,开发人员应该考虑到软件易用、兼容性、安全性等方面,确保软件能够在企业中得到广泛应用和长期维护。
【出处:滨海网站建设 http://www.1234xp.com/binhai.html 复制请保留原URL】