Exemple #1
0
        public static string InitInventory(string iccode, string icode)
        {
            string r = "";
            Sys_InventoryDetail      sid  = new Sys_InventoryDetail();
            Sys_InventoryDetailBll   sidb = new Sys_InventoryDetailBll();
            Sys_InventoryCategory    sic  = new Sys_InventoryCategory();
            Sys_InventoryCategoryBll sicb = new Sys_InventoryCategoryBll();
            SessionUserValidate      iv   = SysValidateBll.ValidateSession();

            if (iv.f)
            {
                sic = sicb.Query(" and iccode='" + iccode + "'");
                if (icode == "")
                {
                    if (sic != null)
                    {
                        sid.iccode = sic.iccode;
                        sid.icname = sic.icname;
                        sid.iname  = sic.icname;
                    }
                    else
                    {
                        sid.iccode = "";
                        sid.icname = "";
                        sid.iname  = "";
                    }
                    sid.icode  = iccode + sidb.CreateCode(iccode).ToString().PadLeft(3, '0');
                    sid.istate = true;
                    sid.id     = 0;
                }
                else
                {
                    sid = sidb.Query(" and icode='" + icode + "'");
                }
                r = js.Serialize(sid);
            }
            else
            {
                r = iv.badstr;
            }
            return(r);
        }
Exemple #2
0
        public static ArrayList BatchSaveInventory(string iccode, string plmname, string plsize, string pltype, string plunit)
        {
            ArrayList r = new ArrayList();
            Sys_InventoryDetailBll   sidb = new Sys_InventoryDetailBll();
            Sys_MaterialBll          sub  = new Sys_MaterialBll();
            List <Sys_Material>      lsr  = new List <Sys_Material>();
            Sys_InventoryCategoryBll sicb = new Sys_InventoryCategoryBll();
            SessionUserValidate      iv   = SysValidateBll.ValidateSession();

            if (iv.f)
            {
                List <Sys_InventoryCategory> als  = new List <Sys_InventoryCategory>();
                List <Sys_InventoryDetail>   lsid = new List <Sys_InventoryDetail>();
                string[] iarr = iccode.Split(';');
                if (iarr.Length > 0)
                {
                    foreach (string icv in iarr)
                    {
                        List <Sys_InventoryCategory> lic = sicb.QueryList(" and iccode like '" + icv + "%' and icstate='true'");
                        if (lic != null)
                        {
                            foreach (Sys_InventoryCategory sic in lic)
                            {
                                if (!als.Contains(sic))
                                {
                                    als.Add(sic);
                                }
                            }
                        }
                    }
                }
                if (als.Count > 0)
                {
                    r.Add("S");
                    foreach (Sys_InventoryCategory sic in als)
                    {
                        string[] arr   = plmname.Split(';');
                        int      pcnum = sidb.CreateCode(sic.iccode);
                        foreach (string cz in arr)
                        {
                            if (!sidb.Exists(" and iname='" + sic.icname + "' and mname='" + cz + "'"))
                            {
                                Sys_InventoryDetail sid = new Sys_InventoryDetail();
                                sid.icname         = sic.icname;
                                sid.iccode         = sic.iccode;
                                sid.iname          = sic.icname;
                                sid.icode          = sic.iccode + pcnum.ToString().PadLeft(3, '0');
                                sid.mname          = cz;
                                sid.iunit          = plunit;
                                sid.maker          = iv.u.ename;
                                sid.isaleprice     = 0;
                                sid.isupplyprice   = 0;
                                sid.ipurchaseprice = 0;
                                sid.iimage         = "";
                                sid.istate         = true;
                                sid.mcode          = "";
                                sid.idef1          = "";
                                sid.idef2          = true;
                                sid.idef3          = 0;
                                sid.psize          = plsize;
                                sid.cdate          = DateTime.Now.ToString();
                                sid.tcprice        = 0;
                                sid.ptype          = pltype;
                                if (sidb.Add(sid) < 0)
                                {
                                    lsid.Add(sid);
                                }
                                pcnum++;
                            }
                            else
                            {
                                Sys_InventoryDetail fsid = new Sys_InventoryDetail();
                                fsid.mname = cz;
                                fsid.iname = sic.icname;
                                lsid.Add(fsid);
                            }
                        }
                    }
                    if (lsid.Count > 0)
                    {
                        foreach (Sys_InventoryDetail sd in lsid)
                        {
                            ArrayList al = new ArrayList();
                            al.Add(sd.iname);
                            al.Add(sd.mname);
                            r.Add(al);
                        }
                    }
                }
                else
                {
                    r.Add("F");
                }
            }
            else
            {
                r.Add(iv.badstr);
            }
            return(r);
        }
Exemple #3
0
        public static string SaveInventory(string pbz, string pcprice, string pcode, string pcz, string pcztype, string pgprice, string pid, string plcode, string plname, string pname, string psize, string psprice, string pstate, string ptcprice, string ptype, string punit)
        {
            string r     = "";
            string dcode = "00010001";
            Sys_InventoryDetailBll sidb = new Sys_InventoryDetailBll();
            Sys_InventoryDetail    sid  = new Sys_InventoryDetail();
            Sys_MaterialBll        sub  = new Sys_MaterialBll();
            List <Sys_Material>    lsr  = new List <Sys_Material>();
            SessionUserValidate    iv   = SysValidateBll.ValidateSession();

            if (iv.f)
            {
                sid.icname         = plname;
                sid.iccode         = plcode;
                sid.iname          = pname;
                sid.icode          = pcode;
                sid.mname          = pcz;
                sid.iunit          = punit;
                sid.maker          = iv.u.ename;
                sid.isaleprice     = Convert.ToDecimal(psprice);
                sid.isupplyprice   = Convert.ToDecimal(pgprice);
                sid.ipurchaseprice = Convert.ToDecimal(pcprice);
                sid.iimage         = "";
                sid.istate         = pstate == "1" ? true : false;
                sid.mcode          = "";
                sid.idef1          = pbz;
                sid.idef2          = true;
                sid.idef3          = 0;
                sid.psize          = psize;
                sid.cdate          = DateTime.Now.ToString();
                sid.tcprice        = Convert.ToDecimal(ptcprice);
                sid.ptype          = ptype;
                if (pid == "0")
                {
                    if (pcztype == "a")
                    {
                        if (iv.u.dcode != "")
                        {
                            dcode = iv.u.dcode;
                        }
                        lsr = sub.QueryList(" and mstate='true' and mccode in (select mccode from Sys_MaterialCategory where dcode='" + dcode.Substring(0, 8) + "')");
                        if (lsr != null)
                        {
                            foreach (Sys_Material s in lsr)
                            {
                                sid.mname = s.mname;
                                sid.icode = plcode + sidb.CreateCode(plcode).ToString().PadLeft(3, '0');
                                if (!sidb.Exists(" and iname='" + pname + "' and mname='" + s.mname + "'"))
                                {
                                    if (sidb.Add(sid) > 0)
                                    {
                                        r = "S";
                                    }
                                    else
                                    {
                                        r = "F";
                                    }
                                }
                                else
                                {
                                    r = "T";
                                }
                            }
                        }
                    }
                    if (pcztype == "b")
                    {
                        string[] czarr = pcz.Split(';');
                        for (int i = 0; i < czarr.Length; i++)
                        {
                            sid.mname = czarr[i];
                            sid.icode = plcode + sidb.CreateCode(plcode).ToString().PadLeft(3, '0');
                            if (!sidb.Exists(" and iname='" + pname + "' and mname='" + czarr[i] + "'"))
                            {
                                if (sidb.Add(sid) > 0)
                                {
                                    r = "S";
                                }
                                else
                                {
                                    r = "F";
                                }
                            }
                            else
                            {
                                r = "T";
                            }
                        }
                    }
                }
                else
                {
                    if (!sidb.Exists(" and iname='" + pname + "' and mname='" + pcz + "' and icode<>'" + pcode + "'"))
                    {
                        if (sidb.Update(sid))
                        {
                            r = "S";
                        }
                        else
                        {
                            r = "F";
                        }
                    }
                    else
                    {
                        r = "T";
                    }
                }
            }
            else
            {
                r = iv.badstr;
            }
            return(r);
        }