Пример #1
0
        public int InDepositoryConfirm(string acode, string yhdm)
        {
            DataTable         table = AllocationAction.GetAllocation_StockList("sma.acode='" + acode + "' and flowstate=1 and isouta=1 ");
            int               num   = 0;
            TreasuryPermitBll bll   = new TreasuryPermitBll();
            AllocationModel   model = new AllocationModel();

            model = this.ReturnAllocatonModel(" acode='" + acode + "' ");
            if (!bll.IsPermitAccept(model.Acode, yhdm))
            {
                return(0);
            }
            if (table.Rows.Count > 0)
            {
                TreasuryStock      stock  = new TreasuryStock();
                TreasuryStockModel model2 = new TreasuryStockModel();
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    model2.corp    = table.Rows[i]["corp"].ToString();
                    model2.incode  = acode;
                    model2.intime  = DateTime.Now;
                    model2.intype  = 0;
                    model2.Type    = "A";
                    model2.isfirst = false;
                    model2.scode   = table.Rows[i]["scode"].ToString();
                    model2.snumber = decimal.Parse(table.Rows[i]["number"].ToString());
                    model2.sprice  = decimal.Parse(table.Rows[i]["sprice"].ToString());
                    model2.tcode   = table.Rows[i]["tcodeb"].ToString();
                    model2.tsid    = Guid.NewGuid().ToString();
                    if (stock.Add(model2) <= 0)
                    {
                        return(-1);
                    }
                    AllocationAction.UpdateState(true, true, acode, "In");
                    num = 1;
                }
            }
            return(num);
        }
Пример #2
0
        public int OutDepositoryConfirm(string acode, string yhdm)
        {
            DataTable         table = AllocationAction.GetAllocation_StockList("sma.acode='" + acode + "' and flowstate=1 ");
            DataTable         materialDetailsOfDeposity = new DataTable();
            int               num  = 0;
            decimal           num2 = 0M;
            TreasuryPermitBll bll  = new TreasuryPermitBll();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                decimal num4 = 0M;
                bool    flag = bll.IsPermitBool(table.Rows[i]["tcodea"].ToString(), yhdm);
                object  materialNumberOfDepository = AllocationAction.GetMaterialNumberOfDepository(table.Rows[i]["tcodea"].ToString(), " scode='" + table.Rows[i]["scode"].ToString() + "' and sprice='" + table.Rows[i]["sprice"].ToString() + "' and corp='" + table.Rows[i]["corp"].ToString() + "' ");
                if (!flag)
                {
                    num = -3;
                    break;
                }
                if (materialNumberOfDepository != null)
                {
                    num4 = decimal.Parse(materialNumberOfDepository.ToString());
                }
                num2 = decimal.Parse(table.Rows[i]["number"].ToString());
                if (num4 < num2)
                {
                    num = -2;
                    break;
                }
            }
            switch (num)
            {
            case -2:
            case -3:
                return(num);

            default:
                for (int j = 0; j < table.Rows.Count; j++)
                {
                    decimal num6 = 0M;
                    num6 = decimal.Parse(table.Rows[j]["number"].ToString());
                    materialDetailsOfDeposity = AllocationAction.GetMaterialDetailsOfDeposity("tcode='" + table.Rows[j]["tcodea"].ToString() + "' and scode='" + table.Rows[j]["scode"].ToString() + "' and sprice='" + table.Rows[j]["sprice"].ToString() + "' and corp='" + table.Rows[j]["corp"].ToString() + "' order by intime asc ");
                    for (int k = 0; k < materialDetailsOfDeposity.Rows.Count; k++)
                    {
                        decimal num8 = 0M;
                        num8 = decimal.Parse(materialDetailsOfDeposity.Rows[k]["snumber"].ToString());
                        if (num8 > num6)
                        {
                            if (AllocationAction.UpdateNumberOfTreasury(materialDetailsOfDeposity.Rows[k]["tsid"].ToString(), num8 - num6) <= 0)
                            {
                                num = -1;
                            }
                            else
                            {
                                Common2.AlarmMethod(table.Rows[j]["tcodea"].ToString(), table.Rows[j]["scode"].ToString());
                            }
                            break;
                        }
                        if (num8 == num6)
                        {
                            if (new TreasuryStock().Delete(materialDetailsOfDeposity.Rows[k]["tsid"].ToString()) <= 0)
                            {
                                num = -1;
                            }
                            else
                            {
                                Common2.AlarmMethod(table.Rows[j]["tcodea"].ToString(), table.Rows[j]["scode"].ToString());
                            }
                            break;
                        }
                        if (num8 < num6)
                        {
                            if (new TreasuryStock().Delete(materialDetailsOfDeposity.Rows[k]["tsid"].ToString()) <= 0)
                            {
                                num = -1;
                                break;
                            }
                            num6 -= num8;
                            Common2.AlarmMethod(table.Rows[j]["tcodea"].ToString(), table.Rows[j]["scode"].ToString());
                        }
                    }
                    if (num == -1)
                    {
                        break;
                    }
                    num = 1;
                }
                break;
            }
            if (num == 1)
            {
                AllocationAction.UpdateState(true, false, acode, "Out");
            }
            return(num);
        }