예제 #1
0
    private ToDoListStockinOrderData GetData()
    {
        ToDoListStockinOrderData data = new ToDoListStockinOrderData();
        data.RECEIVEDATE = DateTime.Now.Date;
        data.RECEIVER = Authz.CurrentUserInfo.Warehouse;
        data.SENDER = Authz.CurrentUserInfo.Warehouse;
        data.STATUS = Constz.Requisition.Status.Waiting.Code;

        string orderType = "";
        string supplierName = "";
        double sender = 0;

        for (int i = 0; i < this.grvRequisition.Rows.Count; ++i)
        {
            CheckBox chk = (CheckBox)this.grvRequisition.Rows[i].Cells[indexCheckBox].FindControl("chkItem");
            if (chk.Checked && chk.Enabled && this.grvRequisition.Rows[i].Cells[indexCheckBox].CssClass != "zhidden")
            {
                if (orderType == "")
                    orderType = this.grvRequisition.Rows[i].Cells[indexOrderType].Text;
                else if (orderType != this.grvRequisition.Rows[i].Cells[indexOrderType].Text)
                    throw new ApplicationException("äÁèÊÒÁÒö·ÓÃÒ¡ÒÃä´é à¹×èͧ¨Ò¡äÁèãªè»ÃÐàÀ·¤ÓÊÑè§à´ÕÂǡѹ");

                if (supplierName == "")
                    supplierName = this.grvRequisition.Rows[i].Cells[indexSupplierName].Text;
                else if (supplierName != this.grvRequisition.Rows[i].Cells[indexSupplierName].Text)
                     throw new ApplicationException("äÁèÊÒÁÒö·ÓÃÒ¡ÒÃä´é à¹×èͧ¨Ò¡äÁèãªè¼Ùé¨Ó˹èÒ´ÕÂǡѹ");

                 sender = Convert.ToDouble(this.grvRequisition.Rows[i].Cells[indexSupplier].Text);

                ToDoListStockInOrderItemData itemData = new ToDoListStockInOrderItemData();
                itemData.PRODUCT = Convert.ToDouble(this.grvRequisition.Rows[i].Cells[indexProduct].Text);
                itemData.QTY = Convert.ToDouble(this.grvRequisition.Rows[i].Cells[indexRemain].Text);
                itemData.LOTNO = "";
                string price = this.grvRequisition.Rows[i].Cells[indexPrice].Text;
                itemData.PRICE = Convert.ToDouble(price == "" ? "0" : price);
                itemData.REFLOID = Convert.ToDouble(this.grvRequisition.Rows[i].Cells[indexLOID].Text);
                if (orderType == Constz.OrderType.PD.Code)
                    itemData.REFTABLE = "PDPRODUCT";
                else
                    itemData.REFTABLE = "POITEM";
                itemData.STATUS = Constz.Requisition.Status.Waiting.Code;
                itemData.UNIT = Convert.ToDouble(this.grvRequisition.Rows[i].Cells[indexUnit].Text);
                data.ACCCODE = this.grvRequisition.Rows[i].Cells[indexRequestCode].Text;
                
                data.ITEM.Add(itemData);
            }
        }
        if (orderType == Constz.OrderType.PD.Code)
            data.DOCTYPE = Constz.DocType.DelRaw.LOID;
        else if (orderType == Constz.OrderType.PO.Code)
            data.DOCTYPE = Constz.DocType.RecRaw.LOID;
        data.SENDER = sender;
        _orderType = orderType;
        return data;
    }
예제 #2
0
        public bool NewStockIn(string UserID, ToDoListStockinOrderData data)
        {
            bool ret = true;
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            try
            {
                StockInDAL _DAL = new StockInDAL();
                _DAL.OnDB = false;
                _DAL.ACCCODE = data.ACCCODE;
                _DAL.DOCTYPE = data.DOCTYPE;
                _DAL.RECEIVEDATE = data.RECEIVEDATE;
                _DAL.RECEIVER = data.RECEIVER;
                _DAL.SENDER = data.SENDER;
                _DAL.STATUS = data.STATUS;

                ret = _DAL.InsertCurrentData(UserID, obj.zTrans);
                if (!ret)
                {
                    throw new ApplicationException(_DAL.ErrorMessage);
                }
                StockInItemDAL _DALItem = new StockInItemDAL();
                for (int i = 0; i < data.ITEM.Count; ++i)
                {
                    _DALItem.OnDB = false;
                    ToDoListStockInOrderItemData itemData = (ToDoListStockInOrderItemData)data.ITEM[i];
                    _DALItem.LOTNO = itemData.LOTNO;
                    _DALItem.PRICE = itemData.PRICE;
                    _DALItem.PRODUCT = itemData.PRODUCT;
                    _DALItem.QTY = itemData.QTY;
                    _DALItem.REFLOID = itemData.REFLOID;
                    _DALItem.REFTABLE = itemData.REFTABLE;
                    _DALItem.STATUS = itemData.STATUS;
                    _DALItem.STOCKIN = _DAL.LOID;
                    _DALItem.UNIT = itemData.UNIT;
                    ret = _DALItem.InsertCurrentData(UserID, obj.zTrans);
                    if (!ret)
                    {
                        throw new ApplicationException(_DALItem.ErrorMessage);
                    }
                }

                _LOID = _DAL.LOID;

                obj.zTrans.Commit();
                obj.CloseConnection();
            }
            catch (Exception ex)
            {
                obj.zTrans.Rollback();
                obj.CloseConnection();
                ret = false;
                _error = ex.Message;
            }
            return ret;
        }