コード例 #1
0
        private void CreateNewItemStockInNote()
        {
            if (mEditMode != EditMode.CreateNew)
                return;

            String itemSku = this.textBoxItemSKU.Text;
            if (itemSku == "")
            {
                MessageBox.Show("商品sku错误!", "抱歉", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            InventoryItemType item = ItemDAL.GetItemBySKU(itemSku);
            if (item == null)
            {
                MessageBox.Show("无此sku商品!", "抱歉", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            String sourcingNoteIdStr = this.textBoxSourcingNoteId.Text;

            String stockInNumStr = this.textBoxStockInNum.Text;
            int stockInNum = 0;
            if (stockInNumStr == "" || !Int32.TryParse(stockInNumStr, out stockInNum))
            {
                MessageBox.Show("商品入库数量错误!", "抱歉", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            DateTime stockInDate = this.dateTimePickerStockInTime.Value;

            ItemStockInNoteType note = new ItemStockInNoteType();
            note.ItemSKU = itemSku;
            note.ItemTitle = item.ItemName;
            note.SourcingNoteId = sourcingNoteIdStr;
            note.StockInNum = stockInNum;
            note.StockInDate = stockInDate;
            note.Comment = textBoxComment.Text;

            int noteId = ItemStockInNoteDAL.InsertOneItemStockInNote(note);
            if (noteId <= 0)
            {
                MessageBox.Show("创建入库单失败!", "抱歉", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Increase the item stock number.
            ItemDAL.IncreaseItem(itemSku, stockInNum);

            MessageBox.Show(String.Format("创建入库单成功,入库单号{0}!", noteId),
                "恭喜", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
コード例 #2
0
        public static int InsertOneItemStockInNote(ItemStockInNoteType note)
        {
            IDbCommand cmd = DataFactory.CreateCommand(null);
            cmd.CommandText = @"Insert into [ItemStockInNote] (ItemSKU, ItemTitle, SourcingNoteId, StockInNum, StockInDate, Comment) values"
                    + "(@ItemSKU, @ItemTitle, @SourcingNoteId, @StockInNum, @StockInDate, @Comment)";

            DataFactory.AddCommandParam(cmd, "@ItemSKU", DbType.String, note.ItemSKU);
            DataFactory.AddCommandParam(cmd, "@ItemTitle", DbType.String, note.ItemTitle);
            DataFactory.AddCommandParam(cmd, "@SourcingNoteId", DbType.String, note.SourcingNoteId);
            DataFactory.AddCommandParam(cmd, "@StockInNum", DbType.Int32, note.StockInNum);
            DataFactory.AddCommandParam(cmd, "@StockInDate", DbType.DateTime, note.StockInDate.ToShortDateString());
            DataFactory.AddCommandParam(cmd, "@Comment", DbType.String, note.Comment);

            int newId = 0;

            try
            {
                if (DataFactory.DbConnection.State == ConnectionState.Closed)
                    DataFactory.DbConnection.Open();
                cmd.ExecuteNonQuery();

                IDbCommand cmdNewID = DataFactory.CreateCommand("SELECT @@IDENTITY");
                // Retrieve the Autonumber and store it in the CategoryID column.
                object obj = cmdNewID.ExecuteScalar();
                Int32.TryParse(obj.ToString(), out newId);
            }
            catch (DataException)
            {
                // Write to log here.
            }
            finally
            {
                if (DataFactory.DbConnection.State == ConnectionState.Open)
                    DataFactory.DbConnection.Close();
            }

            return newId;
        }
コード例 #3
0
 private static ItemStockInNoteType GetItemStockInNoteFromDataRow(DataRow dr)
 {
     ItemStockInNoteType note = new ItemStockInNoteType();
     note.NoteId = StringUtil.GetSafeInt(dr["NoteId"]);
     note.ItemSKU = StringUtil.GetSafeString(dr["ItemSKU"]);
     note.ItemTitle = StringUtil.GetSafeString(dr["ItemTitle"]);
     note.SourcingNoteId = StringUtil.GetSafeString(dr["SourcingNoteId"]);
     note.StockInNum = StringUtil.GetSafeInt(dr["StockInNum"]);
     note.StockInDate = StringUtil.GetSafeDateTime(dr["StockInDate"]);
     note.Comment = StringUtil.GetSafeString(dr["Comment"]);
     return note;
 }
コード例 #4
0
        public static bool ModifyOneItemStockInNote(ItemStockInNoteType note)
        {
            bool result = false;

            if (note == null || note.NoteId <= 0)
                return false;

            IDbCommand cmd = DataFactory.CreateCommand(null);
            cmd.CommandText = @"Update [ItemStockInNote] set [email protected], [email protected], [email protected], "
                    + "[email protected], [email protected], [email protected] where [email protected]";

            DataFactory.AddCommandParam(cmd, "@ItemSKU", DbType.String, note.ItemSKU);
            DataFactory.AddCommandParam(cmd, "@ItemTitle", DbType.String, note.ItemTitle);
            DataFactory.AddCommandParam(cmd, "@SourcingNoteId", DbType.String, note.SourcingNoteId);
            DataFactory.AddCommandParam(cmd, "@StockInNum", DbType.Int32, note.StockInNum);
            DataFactory.AddCommandParam(cmd, "@StockInDate", DbType.DateTime, note.StockInDate);
            DataFactory.AddCommandParam(cmd, "@Comment", DbType.String, note.Comment);

            DataFactory.AddCommandParam(cmd, "@NoteId", DbType.Int32, note.NoteId);

            try
            {
                if (DataFactory.DbConnection.State == ConnectionState.Closed)
                    DataFactory.DbConnection.Open();
                cmd.ExecuteNonQuery();
                result = true;

            }
            catch (DataException)
            {
                // Write to log here.
                result = false;
            }
            finally
            {
                if (DataFactory.DbConnection.State == ConnectionState.Open)
                    DataFactory.DbConnection.Close();
            }

            return result;
        }