Beispiel #1
0
 public void CreateClientRequire(t_labels label)
 {
     CreateClientRequireThree(label);
     CreateClientRequireTwo(label);
     CreateClientRequireOne(label);
 }
Beispiel #2
0
        /// <summary>
        ///  这里没事务保存会错的
        /// </summary>
        /// <param name="label"></param>
        /// <param name="createQty"></param>
        /// <param name="boxQty"></param>
        /// <param name="reelQty"></param>
        /// <param name="box"></param>
        /// <param name="reel"></param>
        /// <returns></returns>

        /* public int InsertLabel(t_labels label, int createQty, int boxQty, int reelQty, int box, int reel)
         * {
         *   int result = 0;
         *   t_opencardpack opencardpack = openCardPackDao.FindOpencardpackByCode(label.code);
         *   if (opencardpack != null)
         *   {
         *       //还是要返回一个数量
         *       //int oldNumber = execProcedureDao.ExecPrSaveSerialNumber(label.clientCode.ToUpper().Trim(), box+reel);
         *       SqlParameter[] param=new SqlParameter[]
         *       {
         *           new SqlParameter("@clientCode",opencardpack.cCusCode),
         *           new SqlParameter("@number",box+reel)
         *       };
         *       int oldNumber = execProcedureDao.ExecPrSaveSerialNumber(param);
         *       label.typeCode = opencardpack.FProductNo;
         *       for (int i = 0; i < reel; i++)
         *       {
         *           label.qty = reelQty.ToString();
         *           label.serialNumber = oldNumber;
         *           label.workOrder = opencardpack.Fwono;
         *           //检查重要是否为空
         *           int objectNull =ObjectIsNull(label);
         *           if (objectNull<=0)
         *           {
         *               return 0;
         *           }
         *           result=tLabelsDao.InsertLabel(label);
         *           if (result == 0)
         *           {
         *               break;
         *           }
         *           oldNumber++;
         *       }
         *       for (int i = 0; i < box; i++)
         *       {
         *           label.qty = boxQty.ToString();
         *           label.serialNumber = oldNumber;
         *           result=tLabelsDao.InsertLabel(label);
         *           if (result == 0)
         *           {
         *               break;
         *           }
         *           oldNumber++;
         *       }
         *   }
         *   return result;
         * }*/
        /// <summary>
        /// 添加标签信息
        /// </summary>
        /// <param name="label">标签对象</param>
        /// <param name="createQty">生成的总数</param>
        /// <param name="boxQty">盒子数量</param>
        /// <param name="reelQty">卷盘数量</param>
        /// <param name="box">盒子标签数量</param>
        /// <param name="reel">卷盘标签数量</param>
        /// <returns></returns>
        public int InsertLabel(t_labels label, int createQty, int boxQty, int reelQty, int box, int reel, Boolean isBoxPack)
        {
            List <t_labels> labels       = new List <t_labels>();
            int             result       = 0;
            t_opencardpack  opencardpack = openCardPackDao.FindOpencardpackByCode(label.code);

            if (opencardpack != null)
            {
                string uidCode = null;
                if (label.labelTemplateAddressId != 235)
                {
                    uidCode = label.clientCode.Trim();
                    string[] tpv = new[] { "T4003", "T4011", "T4017", "T4021", "T4022", "T4027", "T4008", "T4012", "T4016", "T4023" };
                    if (tpv.Contains(uidCode))
                    {
                        uidCode = "TPV";
                    }
                }
                else
                {
                    uidCode = "STANDARD";
                }
                SqlParameter[] param = new SqlParameter[]
                {
                    new SqlParameter("@clientCode", uidCode),
                    new SqlParameter("@number", box + reel)
                };
                //通过存储过程获取流水号
                long oldNumber = execProcedureDao.ExecPrSaveSerialNumber(param);
                //label.typeCode = opencardpack.FProductNo;
                label.workOrder = opencardpack.Fwono;
                //获取服务器时间
                label.createDate = customUtilityDao.GetServerDateTime().ToString("yyyy-MM-dd HH:mm:ss");
                //最小包装非内盒
                if (!isBoxPack)
                {
                    int tempReelQty = createQty;
                    for (int i = 0; i < reel; i++)
                    {
                        t_labels newLabes = FanShe.Mapper <t_labels, t_labels>(label);
                        if (tempReelQty > reelQty)
                        {
                            newLabes.qty = reelQty;
                        }
                        else
                        {
                            newLabes.qty = tempReelQty;
                        }
                        tempReelQty           = tempReelQty - reelQty;
                        newLabes.serialNumber = oldNumber;
                        newLabes.UID          = CreateUID(newLabes);
                        newLabes.packType     = 1; //1为卷盘包装类型 2为内盒包装类型 3为外箱包装类型

                        //添加客户特殊要求
                        Label_template template     = labelTemplateDao.FindLabelTemplatesById(label.labelTemplateAddressId);
                        string         templateName = template.Label_describe.Trim().ToUpper();
                        //newLabes引用类型返回和不返回一样,所以这里调用一下那标签对象了
                        clientRequireFactoryBll.InsertClientRequire(newLabes, templateName);

                        //检查重要属性是否为空
                        int objectNull = ObjectIsNull(newLabes);
                        if (objectNull <= 0)
                        {
                            return(0);
                        }
                        labels.Add(newLabes); //执行添加标签信息
                        oldNumber++;
                    }
                }
                int tempBoxQty = createQty;
                for (int i = 0; i < box; i++)
                {
                    t_labels newLabes = FanShe.Mapper <t_labels, t_labels>(label);
                    if (tempBoxQty > boxQty)
                    {
                        newLabes.qty = boxQty;
                    }
                    else
                    {
                        newLabes.qty = tempBoxQty;
                    }
                    tempBoxQty            = tempBoxQty - boxQty;
                    newLabes.serialNumber = oldNumber;
                    newLabes.UID          = CreateUID(newLabes);
                    newLabes.packType     = 2;
                    Label_template template     = labelTemplateDao.FindLabelTemplatesById(label.labelTemplateAddressId);
                    string         templateName = template.Label_describe.Trim().ToUpper();
                    clientRequireFactoryBll.InsertClientRequire(newLabes, templateName);
                    //检查重要属性是否为空
                    int objectNull = ObjectIsNull(newLabes);
                    if (objectNull <= 0)
                    {
                        return(0);
                    }
                    labels.Add(newLabes);
                    oldNumber++;
                }
                //保存前再次确认生成的标签数量与前台计算的标签数量是否一致才保存
                result = labels.Count == (box + reel) ? tLabelsDao.InsertLabel(labels) : 0;
            }
            return(result);
        }
Beispiel #3
0
 public TPVBllImpl(t_labels label)
 {
     CreateClientRequire(label);
 }
 public int PrintLabels(t_labels label, int printcount, int[] ids, ref string message)
 {
     return(printLabelsBll.PrintLabel(label, printcount, ids, ref message));
 }
        /// <summary>
        /// 生成或打印
        /// </summary>
        /// <param name="createAndPrint">Boolean true 生成并打印   false 生成</param>
        public void CreateLabelOrPrint(Boolean createAndPrint)
        {
            int createqty = int.Parse(this.txtCreateQTY.Text.Trim());
            //订单数量控制
            Boolean verify = frmCreateLabelsBll.VerifyOrderQty(this.txtOrder.Text.Trim(), this.txtTypeCode.Text.Trim(), createqty);

            if (!verify)
            {
                MessageBox.Show(@"超出订单数量!", messageHead, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            int labelTemplateId = 0;
            FrmSelectTemplate frmSelectTemplate = FrmSelectTemplate.GetSingle(
                delegate()
            {
                string[] tpv = new[] { "T4003", "T4011", "T4017", "T4021", "T4022", "T4027", "T4008", "T4012", "T4016", "T4023" };
                if (tpv.Contains(this.txtClientCode.Text.Trim()))
                {
                    return("TPV");
                }
                return(this.txtClientCode.Text.Trim());
            },
                delegate(int id)
            {
                labelTemplateId = id;
            }
                );

            frmSelectTemplate.ShowDialog();
            //MessageBox.Show(@"别瞎点了,此功能没开发呢!", messageHead, MessageBoxButtons.OK, MessageBoxIcon.Information);
            if (labelTemplateId != 0)
            {
                t_labels label = new t_labels();
                label.clientCode = this.txtClientCode.Text.Trim();
                if (string.IsNullOrEmpty(this.txtBatchSuffix.Text))
                {
                    label.batchNo = this.txtBatch.Text.Trim();
                }
                else
                {
                    label.batchNo = this.txtBatch.Text.Trim() + this.txtBatchSuffix.Text;
                }
                label.code = this.txtKey.Text.Trim();
                //日期这里要优化一下,拿客户端时间有风险   2018-7-12已经处理
                //label.createDate = DateTime.Now.ToString();
                if (string.IsNullOrEmpty(this.txtFlowCardSuffix.Text))
                {
                    label.flowCard = this.txtFlowCard.Text.Trim();
                }
                else
                {
                    label.flowCard = this.txtFlowCard.Text.Trim() + "  " + this.txtFlowCardSuffix.Text;
                }
                label.labelTemplateAddressId = labelTemplateId;
                label.orderCode    = this.txtOrder.Text.Trim();
                label.package      = this.txtZhuShen.Text.Trim();
                label.pn           = this.txtPN.Text.Trim();
                label.po           = this.txtPO.Text.Trim();
                label.shipmentDate = this.txtDpredate.Text.Trim();
                label.type         = this.txtCinvstd.Text.Trim();
                label.remark       = this.txtNote.Text.Trim();
                label.typeCode     = this.txtTypeCode.Text.Trim();
                //int labelQty = Int32.Parse(this.txtBox.Text) + Int32.Parse(this.txtReel.Text);
                int orderQty = int.Parse(this.txtOrderQty.Text.Trim()); // 订单数量
                int boxQTY   = int.Parse(this.txtBoxQTY.Text.Trim());   //内盒数量
                int reelQTY  = int.Parse(this.txtReelQTY.Text.Trim());  //卷盘数量
                int box      = int.Parse(this.txtBox.Text.Trim());      //内盒个数
                int reel     = int.Parse(this.txtReel.Text.Trim());     //卷盘个数
                //Label_template labeltempalte = frmCreateLabelsBll.FindLabelTemplateById(labelTemplateId);
                string messages = null;
                int    result   = frmCreateLabelsBll.InsertLabel(label, orderQty, boxQTY, reelQTY, box, reel, this.cb_pack.Checked);
                if (result > 0)
                {
                    //MessageBox.Show(@"生成成功!", messageHead, MessageBoxButtons.OK, MessageBoxIcon.Information);

                    if (createAndPrint)
                    {
                        int printResult = printLabelsBll.PrintLabel(label, 1, null, ref messages);
                        if (printResult < 0)
                        {
                            MessageBox.Show(@"打印失败!" + messages, messageHead, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                else
                {
                    MessageBox.Show(@"生成失败!", messageHead, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                ClearGroupBoxText();
                this.btnCreate.Enabled         = false;
                this.btnCreateAndPrint.Enabled = false;
            }
        }
Beispiel #6
0
 public void CreateClientRequireFive(t_labels label)
 {
     throw new NotImplementedException();
 }
Beispiel #7
0
 public void CreateClientRequire(t_labels label)
 {
     label.vendorCode = _vendorCode;
     CreateClientRequireOne(label);
     CreateClientRequireTwo(label);
 }
 /// <summary>
 /// 年周yyweek
 /// </summary>
 /// <param name="label">t_labels 标签信息</param>
 public void CreateClientRequireTwo(t_labels label)
 {
     label.ClientRequireTwo = CustomFormatDate.GetyyWeek(label.createDate);
 }
 public A0024BllImpl(t_labels label)
 {
     CreateClientRequire(label);
 }
        public int PrintLabel(t_labels label, int printcount, int[] ids, ref string message)
        {
            Engine engin = null;
            LabelFormatDocument format = null;

            try
            {
                engin = new Engine(true);
                Label_template           template = labelTemplateDao.FindLabelTemplatesById(label.labelTemplateAddressId);
                SystemDatabaseConnection conn     = new SystemDatabaseConnection();
                conn.Method         = SystemDatabaseConnectionMethod.Manual;
                conn.Authentication = SystemDatabaseAuthenticationMethod.SQLServer;
                conn.ServerName     = @"192.168.1.201";
                conn.DatabaseName   = "ERP2008";
                conn.UserName       = "******";
                conn.Password       = "******";
                conn.Connect();
                string sqlcommand = null;
                if (ids.Length == 0 || ids == null)
                {
                    sqlcommand = "SELECT * FROM  dbo.t_labels WHERE code='" + label.code + "'";
                }
                else
                {
                    sqlcommand = "SELECT * FROM  t_labels WHERE  autoid IN( ";
                    foreach (int id in ids)
                    {
                        sqlcommand = sqlcommand + id + ",";
                    }
                    sqlcommand = sqlcommand.Substring(0, sqlcommand.Length - 1);
                    sqlcommand = sqlcommand + ")";
                }
                OLEDB oledb = new OLEDB("ERP2008");
                oledb.SQLStatement = sqlcommand;
                format             = engin.Documents.Open(template.Label_Path, template.Print_Cmd);
                format.DatabaseConnections.SetDatabaseConnection(oledb);
                format.PrintSetup.IdenticalCopiesOfLabel = printcount; //默认打印一张
                Messages mes;
                Result   result = format.Print(template.Label_describe + "-" + template.Label_NO, 10000);
                if (Result.Failure == result)
                {
                    message += result;
                    return(0);
                }
                else if (Result.Success == result)
                {
                    message += result;
                    return(0);
                }

                return(1);
            }
            catch (Exception e)
            {
                message += e.Message;
                return(0);
            }
            finally
            {
                if (format != null)
                {
                    format.Close(SaveOptions.DoNotSaveChanges);
                }
                if (engin != null)
                {
                    engin.Stop();
                }
            }
        }