吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1275|回复: 33
上一主题 下一主题
收起左侧

[C&C++ 转载] 库存管理

  [复制链接]
跳转到指定楼层
楼主
再贱就再见 发表于 2026-10-26 09:25 回帖奖励
本帖最后由 再贱就再见 于 2026-10-26 14:34 编辑

转载个电脑+手机配合的进销存软件,管库存、管批号效期、管单据、能打印能导出,手机上还能扫码和拍照直接录入

所有的单据名称表头,都可以自己设置改名

这个软件还有个彩蛋


主要功能电脑端
  • 入库/出库 —— 数量正负加减,名称规格批号效期一改就按新物品记;库存不足自动拦
  • 库存管理 —— 十多个字段可显示/隐藏、可改名,支持名称和拼音首字母搜索,分页浏览
  • 预警提醒 —— 临期、过期、低库存,启动自动弹窗,天数/阈值可设
  • 出入库单据 —— 自动单号,可合并、可撤销合并,按时间范围导出
  • 导出打印 —— 库存导 Excel,单据导网页打印/另存 PDF;字号边距单号大小可调,也能自定义模板
  • 系统设置 —— 软件改名(自动改 exe 名)、密码、窗口大小、字段名称

手机端
    7. 扫码入库/出库 —— 扫条码或二维码,匹配库存后填数量,可以一直扫,点取消才退出
    8. 拍照识别 —— 拍包装自动识别名称、规格、批号、有效期等,逐行勾选、可改字、可指定字段后入库
    9. 手机出库 —— 列表选物品填数量即可,电脑端同步生成出库单
   10. 跟电脑一套规则 —— 电脑隐藏的字段手机也不显示;电脑改的字段名手机同步共同点:不用数据库、不用服务器、不用联网,数据是 CSV 文本,随时备份,Excel 能打开核对。




更新了出库少于库存的提醒,可以设置提醒字体大小
更新了出库单入库单可以加备注
更新了可以自定义设置提醒的颜色
https://wwbmj.lanzouu.com/iG1dr4dfzjyb
密码:h216


觉得有用的请给与支持!!!
觉得有用的请给与支持!!!
觉得有用的请给与支持!!!

[C] 纯文本查看 复制代码
#include "document.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define IN_HDR  "data/inbound_docs.csv"
#define IN_DET  "data/inbound_lines.csv"
#define OUT_HDR "data/outbound_docs.csv"
#define OUT_DET "data/outbound_lines.csv"

static const char *hdr_path(DocType t) { return t == DOC_IN ? IN_HDR : OUT_HDR; }
static const char *det_path(DocType t) { return t == DOC_IN ? IN_DET : OUT_DET; }

int docs_load_from(DocStore *store, DocType type, const char *hdr_file, const char *det_file) {
    FILE *fh, *fd;
    char line[MAX_LINE];
    char *fields[16];
    int i;

    memset(store, 0, sizeof(*store));
    fh = fopen(hdr_file, "rb");
    if (!fh) return 0;
    {
        unsigned char bom[3];
        size_t n = fread(bom, 1, 3, fh);
        if (!(n == 3 && bom[0] == 0xEF && bom[1] == 0xBB && bom[2] == 0xBF))
            fseek(fh, 0, SEEK_SET);
    }
    if (!fgets(line, sizeof(line), fh)) { fclose(fh); return 0; }
    while (fgets(line, sizeof(line), fh) && store->count < MAX_DOCS) {
        size_t len = strlen(line);
        Document *doc;
        int nf;
        while (len > 0 && (line[len - 1] == '\n' || line[len - 1] == '\r'))
            line[--len] = '\0';
        if (!line[0]) continue;
        nf = csv_split(line, fields, 16);
        if (nf < 2) continue;
        doc = &store->docs[store->count];
        memset(doc, 0, sizeof(*doc));
        safe_copy(doc->docno, sizeof(doc->docno), fields[0]);
        safe_copy(doc->datetime, sizeof(doc->datetime), fields[1]);
        doc->type = type;

        if (nf >= 9 && strcmp(fields[2], "入库") != 0 && strcmp(fields[2], "出库") != 0) {
            safe_copy(doc->hdr_a, sizeof(doc->hdr_a), fields[2]);
            safe_copy(doc->hdr_b, sizeof(doc->hdr_b), fields[3]);
            safe_copy(doc->hdr_c, sizeof(doc->hdr_c), fields[4]);
            safe_copy(doc->recv_unit, sizeof(doc->recv_unit), fields[5]);
            safe_copy(doc->recv_person, sizeof(doc->recv_person), fields[6]);
            safe_copy(doc->handler, sizeof(doc->handler), fields[7]);
            safe_copy(doc->auditor, sizeof(doc->auditor), fields[8]);
        } else if (nf >= 6 && strcmp(fields[2], "入库") != 0 && strcmp(fields[2], "出库") != 0) {
            safe_copy(doc->recv_unit, sizeof(doc->recv_unit), fields[2]);
            safe_copy(doc->recv_person, sizeof(doc->recv_person), fields[3]);
            safe_copy(doc->handler, sizeof(doc->handler), fields[4]);
            safe_copy(doc->auditor, sizeof(doc->auditor), fields[5]);
            safe_copy(doc->hdr_a, sizeof(doc->hdr_a), doc->recv_unit);
        }
        doc->line_count = 0;
        store->count++;
    }
    fclose(fh);

    fd = fopen(det_file, "rb");
    if (!fd) return 0;
    {
        unsigned char bom[3];
        size_t n = fread(bom, 1, 3, fd);
        if (!(n == 3 && bom[0] == 0xEF && bom[1] == 0xBB && bom[2] == 0xBF))
            fseek(fd, 0, SEEK_SET);
    }
    if (!fgets(line, sizeof(line), fd)) { fclose(fd); return 0; }
    while (fgets(line, sizeof(line), fd)) {
        Document *doc = NULL;
        Item *it;
        int nf;
        size_t len = strlen(line);
        while (len > 0 && (line[len - 1] == '\n' || line[len - 1] == '\r'))
            line[--len] = '\0';
        if (!line[0]) continue;
        nf = csv_split(line, fields, 16);
        if (nf < 11) continue;
        for (i = 0; i < store->count; i++) {
            if (strcmp(store->docs[i].docno, fields[0]) == 0) {
                doc = &store->docs[i];
                break;
            }
        }
        if (!doc || doc->line_count >= MAX_LINES) continue;
        it = &doc->lines[doc->line_count];
        memset(it, 0, sizeof(*it));
        safe_copy(it->name, sizeof(it->name), fields[1]);
        safe_copy(it->spec, sizeof(it->spec), fields[2]);
        safe_copy(it->mfg, sizeof(it->mfg), fields[3]);
        safe_copy(it->unit, sizeof(it->unit), fields[4]);
        it->qty = atof(fields[5]);
        it->price = atof(fields[6]);

        if (nf >= 12) {
            safe_copy(it->batch, sizeof(it->batch), fields[8]);
            safe_copy(it->prod_date, sizeof(it->prod_date), fields[9]);
            safe_copy(it->expiry, sizeof(it->expiry), fields[10]);
            safe_copy(it->note, sizeof(it->note), fields[11]);
            if (nf >= 13)
                safe_copy(it->inbound_time, sizeof(it->inbound_time), fields[12]);
        } else {
            safe_copy(it->batch, sizeof(it->batch), fields[7]);
            safe_copy(it->prod_date, sizeof(it->prod_date), fields[8]);
            safe_copy(it->expiry, sizeof(it->expiry), fields[9]);
            if (nf > 10) safe_copy(it->note, sizeof(it->note), fields[10]);
        }
        doc->line_count++;
    }
    fclose(fd);

    if (type == DOC_IN) {
        int k;
        for (i = 0; i < store->count; i++) {
            for (k = 0; k < store->docs[i].line_count; k++) {
                Item *it = &store->docs[i].lines[k];
                if (!it->inbound_time[0])
                    safe_copy(it->inbound_time, sizeof(it->inbound_time),
                              store->docs[i].datetime);
            }
        }
    }
    return 0;
}

int docs_load(DocStore *store, DocType type) {
    return docs_load_from(store, type, hdr_path(type), det_path(type));
}

int docs_save_from(const DocStore *store, DocType type, const char *hdr_file, const char *det_file) {
    FILE *fh, *fd;
    int i, j;
    char esc[MAX_NOTE * 2];

    fh = fopen(hdr_file, "wb");
    if (!fh) return -1;
    fputc(0xEF, fh); fputc(0xBB, fh); fputc(0xBF, fh);
    fprintf(fh, "单号,日期时间,头栏A,头栏B,头栏C,领取单位,领取人,经办人,审核人,类型\n");
    for (i = 0; i < store->count; i++) {
        const Document *d = &store->docs[i];
        csv_escape(d->docno, esc, sizeof(esc));
        fprintf(fh, "%s,", esc);
        csv_escape(d->datetime, esc, sizeof(esc));
        fprintf(fh, "%s,", esc);
        csv_escape(d->hdr_a, esc, sizeof(esc));
        fprintf(fh, "%s,", esc);
        csv_escape(d->hdr_b, esc, sizeof(esc));
        fprintf(fh, "%s,", esc);
        csv_escape(d->hdr_c, esc, sizeof(esc));
        fprintf(fh, "%s,", esc);
        csv_escape(d->recv_unit, esc, sizeof(esc));
        fprintf(fh, "%s,", esc);
        csv_escape(d->recv_person, esc, sizeof(esc));
        fprintf(fh, "%s,", esc);
        csv_escape(d->handler, esc, sizeof(esc));
        fprintf(fh, "%s,", esc);
        csv_escape(d->auditor, esc, sizeof(esc));
        fprintf(fh, "%s,%s\n", esc, type == DOC_IN ? "入库" : "出库");
    }
    fclose(fh);

    fd = fopen(det_file, "wb");
    if (!fd) return -1;
    fputc(0xEF, fd); fputc(0xBB, fd); fputc(0xBF, fd);
    fprintf(fd, "单号,通用名称,规格型号,生产企业,单位,数量,单价,金额,产品批号,生产日期,有效期限,备注,入库时间\n");
    for (i = 0; i < store->count; i++) {
        const Document *d = &store->docs[i];
        for (j = 0; j < d->line_count; j++) {
            const Item *it = &d->lines[j];
            csv_escape(d->docno, esc, sizeof(esc));
            fprintf(fd, "%s,", esc);
            csv_escape(it->name, esc, sizeof(esc));
            fprintf(fd, "%s,", esc);
            csv_escape(it->spec, esc, sizeof(esc));
            fprintf(fd, "%s,", esc);
            csv_escape(it->mfg, esc, sizeof(esc));
            fprintf(fd, "%s,", esc);
            csv_escape(it->unit, esc, sizeof(esc));
            fprintf(fd, "%s,", esc);
            fprintf(fd, "%.4f,%.4f,%.2f,", it->qty, it->price, money(it->qty, it->price));
            csv_escape(it->batch, esc, sizeof(esc));
            fprintf(fd, "%s,", esc);
            csv_escape(it->prod_date, esc, sizeof(esc));
            fprintf(fd, "%s,", esc);
            csv_escape(it->expiry, esc, sizeof(esc));
            fprintf(fd, "%s,", esc);
            csv_escape(it->note, esc, sizeof(esc));
            fprintf(fd, "%s,", esc);
            csv_escape(it->inbound_time, esc, sizeof(esc));
            fprintf(fd, "%s\n", esc);
        }
    }
    fclose(fd);
    return 0;
}

int docs_save(const DocStore *store, DocType type) {
    return docs_save_from(store, type, hdr_path(type), det_path(type));
}

static int doc_dt_cmp(const void *a, const void *b) {
    const Document *x = (const Document *)a;
    const Document *y = (const Document *)b;
    int c = strcmp(x->datetime, y->datetime);
    if (c != 0) return c;
    return strcmp(x->docno, y->docno);
}

void docs_sort_by_datetime(DocStore *store) {
    if (!store || store->count < 2) return;
    qsort(store->docs, (size_t)store->count, sizeof(Document), doc_dt_cmp);
}

int docs_append(DocStore *store, const Document *doc) {
    if (store->count >= MAX_DOCS) return -1;
    store->docs[store->count] = *doc;
    store->count++;
    return docs_save(store, doc->type);
}

Document *docs_find(DocStore *store, const char *docno) {
    int i;
    for (i = 0; i < store->count; i++) {
        if (strcmp(store->docs[i].docno, docno) == 0)
            return &store->docs[i];
    }
    return NULL;
}

int docs_restore_outbound(DocStore *out_store, Inventory *inv, const char *docno,
                          char *err, size_t err_n) {
    Document *d;
    int i, idx = -1;
    if (!out_store || !inv || !docno || !docno[0]) {
        if (err && err_n) snprintf(err, err_n, "参数错误");
        return -1;
    }
    for (i = 0; i < out_store->count; i++) {
        if (strcmp(out_store->docs[i].docno, docno) == 0) {
            idx = i;
            break;
        }
    }
    if (idx < 0) {
        if (err && err_n) snprintf(err, err_n, "未找到出库单 %s", docno);
        return -1;
    }
    d = &out_store->docs[idx];
    if (d->type != DOC_OUT) {
        if (err && err_n) snprintf(err, err_n, "只能撤销出库单");
        return -1;
    }

    for (i = 0; i < d->line_count; i++) {
        Item line = d->lines[i];
        int ki = inventory_find_key(inv, &line);
        if (ki >= 0)
            safe_copy(line.inbound_time, sizeof(line.inbound_time),
                      inv->items[ki].inbound_time);
        if (inventory_add_inbound(inv, &line) != 0) {
            if (err && err_n)
                snprintf(err, err_n, "回加库存失败:%s", line.name[0] ? line.name : "?");
            return -1;
        }
    }

    if (idx < out_store->count - 1)
        memmove(&out_store->docs[idx], &out_store->docs[idx + 1],
                (size_t)(out_store->count - idx - 1) * sizeof(Document));
    out_store->count--;
    memset(&out_store->docs[out_store->count], 0, sizeof(Document));
    if (inventory_save(inv) != 0 || docs_save(out_store, DOC_OUT) != 0) {
        if (err && err_n) snprintf(err, err_n, "保存失败");
        return -1;
    }
    return 0;
}

免费评分

参与人数 3吾爱币 +9 热心值 +3 收起 理由
苏紫方璇 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
QaQ355 + 1 + 1 热心回复!
空心 + 1 + 1 已经处理,感谢您对吾爱破解论坛的支持!

查看全部评分

本帖被以下淘专辑推荐:

发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

推荐
 楼主| 再贱就再见 发表于 2026-10-28 16:13 |楼主
心的旅程 发表于 2026-10-28 16:06
感谢分享,发现出入库单面板,在切换成出库时,入库单的备注按钮没有完全消失。

你把这个框提拉大就不会了,我觉得这个框体小了,设置用户拉大框体记忆,就是你设置大小后下次打开还是原来的那么大
推荐
 楼主| 再贱就再见 发表于 2026-10-26 12:46 |楼主
xjfj 发表于 2026-10-26 12:40
楼主能否增加:
1、增加数据导入功能
2、增加项目名称和可修改功能

你要改名称,你直接在原来错的基础上直接修改对的,添加后再把旧的删除就可以了,要不然你等下改了又是错的咋整.
沙发
dupengpeng 发表于 2026-10-26 10:33
谢谢老师的分享,能不能麻烦您在增加一些数据显示,验收环节的内容
3#
 楼主| 再贱就再见 发表于 2026-10-26 10:34 |楼主
dupengpeng 发表于 2026-10-26 10:33
谢谢老师的分享,能不能麻烦您在增加一些数据显示,验收环节的内容

什么意思?第二次确认?
4#
Turbo86 发表于 2026-10-26 10:44
谢谢大佬
5#
风经过 发表于 2026-10-26 10:48
本帖最后由 风经过 于 2026-10-26 10:50 编辑

还会更新吗?看着挺方便的

既然有导出就应该再加入导入功能,这样会更方便
6#
shirker 发表于 2026-10-26 10:58
记得前几天也看到过,更新了吗
7#
dupengpeng 发表于 2026-10-26 11:01
再贱就再见 发表于 2026-10-26 10:34
什么意思?第二次确认?

验收的环节,比如,保存条件、外观是否完整、储存位置之类的选项
8#
守护你de爱 发表于 2026-10-26 11:04
感谢分享辛苦了
9#
zhlezhi 发表于 2026-10-26 11:05
这个确实方便啊,既可以手机端快捷操作,又可以电脑端办公室用,非常棒
10#
CHANGMENG 发表于 2026-10-26 11:28
感谢,好用
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - 52pojie.cn ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2026-11-8 15:03

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表